Created
June 5, 2017 12:43
-
-
Save ompugao/de37a4bddd8ba6af12d45cbfaa128fec to your computer and use it in GitHub Desktop.
keras logistic regression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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