hendriawan icon

06-tensorflow

hendriawan | PRO | 11/28/22 07:07:14 AM UTC | 0 ⭐ | 1310 👁️ | Never ⏰ | []
Python |

580 B

|

None

|

0 👍

/

0 👎

import numpy as np
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
X= np.array([[0,0], [0,1], [1,0], [1,1]], dtype = np.float32)
y= np.array([[0], [1], [1], [0]], dtype = np.float32)
 
model = Sequential()
model.add(Dense(8,input_dim=2,activation='relu'))
model.add(Dense(8, activation = 'relu'))
model.add(Dense(1, activation = 'sigmoid'))
 
model.compile (loss = 'mean_squared_error', optimizer = 'adam', metrics= ['binary_accuracy'])
model.fit(X,y,batch_size=1, epochs=5000,verbose=2)
print(model.summary)
print(model.predict(X))
 
 
 
 

Comments