Advertisement
hendriawan

06-tensorflow

Nov 28th, 2022
973
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import numpy as np
  2. from tensorflow.keras.models import Sequential
  3. from tensorflow.keras.layers import Dense
  4. X= np.array([[0,0], [0,1], [1,0], [1,1]], dtype = np.float32)
  5. y= np.array([[0], [1], [1], [0]], dtype = np.float32)
  6.  
  7. model = Sequential()
  8. model.add(Dense(8,input_dim=2,activation='relu'))
  9. model.add(Dense(8, activation = 'relu'))
  10. model.add(Dense(1, activation = 'sigmoid'))
  11.  
  12. model.compile (loss = 'mean_squared_error', optimizer = 'adam', metrics= ['binary_accuracy'])
  13. model.fit(X,y,batch_size=1, epochs=5000,verbose=2)
  14. print(model.summary)
  15. print(model.predict(X))
  16.  
  17.  
  18.  
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement