Last active
April 28, 2017 11:08
-
-
Save semihyagcioglu/ba151a3781b401eee0a6a41d4c343cd3 to your computer and use it in GitHub Desktop.
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
import numpy as np | |
from keras.models import Sequential | |
from keras.layers.core import Dense | |
X = np.array([[0,0],[0,1],[1,0],[1,1]]) # training data, the states of the XOR gate | |
y = np.array([[0],[1],[1],[0]]) # true labels of the data in the same order | |
model = Sequential() | |
model.add(Dense(16, input_dim=2, activation='relu')) | |
model.add(Dense(1, activation='sigmoid')) | |
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['binary_accuracy']) | |
model.fit(X, y, batch_size=1, nb_epoch=1000, verbose=2) | |
print(model.predict(X).round()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment