SHARE
TWEET

Untitled

a guest Feb 1st, 2017 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. from keras.models import Sequential
  3. from keras.layers.core import Activation, Dense
  4.  
  5. training_data = np.array([[0,0],[0,1],[1,0],[1,1]], "float32")
  6. target_data = np.array([[0],[1],[1],[0]], "float32")
  7.  
  8. model = Sequential()
  9. model.add(Dense(32, input_dim=2, activation='relu'))
  10. model.add(Dense(1, activation='sigmoid'))
  11.  
  12. model.compile(loss='mean_squared_error', optimizer='adam', metrics=['binary_accuracy'])
  13.  
  14. model.fit(training_data, target_data, nb_epoch=1000, verbose=2)
  15.  
  16. print model.predict(training_data)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top