Created
January 24, 2018 21:43
-
-
Save pannous/9325abf169e6440c913e56527a191a9b to your computer and use it in GitHub Desktop.
This file contains hidden or 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, Activation | |
xoder={ | |
(0,0):0, | |
(0,1):1, | |
(1,0):1, | |
(1,1):0 | |
} | |
X=input=np.array([[0,0],[0,1],[1,0],[1,1]]) | |
Y=output=np.array([[1,0],[0,1],[0,1],[1,0]]) | |
model = Sequential() | |
model.add(Dense(10, input_shape=(2,))) | |
model.add(Activation('relu')) | |
model.add(Dense(40)) | |
model.add(Activation('relu')) | |
model.add(Dense(2)) | |
model.add(Activation('softmax')) | |
model.compile(loss='categorical_crossentropy', optimizer='adam',metrics=['acc']) | |
model.fit(input,output,epochs=200) | |
result=model.predict(np.array([[0,1]])) | |
print(result) | |
print(np.argmax(result)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment