Skip to content

Instantly share code, notes, and snippets.

@ompugao
Created June 5, 2017 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ompugao/de37a4bddd8ba6af12d45cbfaa128fec to your computer and use it in GitHub Desktop.
Save ompugao/de37a4bddd8ba6af12d45cbfaa128fec to your computer and use it in GitHub Desktop.
keras logistic regression
from keras.models import Sequential
from keras.layers import Dense, Activation
from keras import backend as K
model = Sequential()
model.add(Dense(output_dim = 1, input_dim=2))
model.add(Activation('sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='sgd', metrics=['accuracy'])
test_inputs = [(0, 0), (0, 1), (1, 0), (1, 1)]
#correct_outputs = [False, False, False, True]
correct_outputs = [1, 0, 1, 0]
model.fit(test_inputs, correct_outputs, batch_size=5, nb_epoch=10000, verbose=1)
from IPython.terminal import embed; ipshell=embed.InteractiveShellEmbed(config=embed.load_default_config())(local_ns=locals())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment