Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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']), y, batch_size=1, nb_epoch=1000, verbose=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment