lab 1: 4 variables fix
This commit is contained in:
parent
ea3668ea54
commit
d5017dc61a
28
lab_1.py
28
lab_1.py
@ -1,17 +1,37 @@
|
||||
import numpy as np
|
||||
from tensorflow.keras import Sequential, Input, layers, optimizers
|
||||
|
||||
x = np.array([[0, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 0], [1, 1, 1]])
|
||||
y = np.array([0, 1, 1, 1, 0, 0, 0, 1])
|
||||
x = np.array([
|
||||
[0, 0, 0, 0],
|
||||
[0, 0, 0, 1],
|
||||
[0, 0, 1, 0],
|
||||
[0, 0, 1, 1],
|
||||
|
||||
[0, 1, 0, 0],
|
||||
[0, 1, 0, 1],
|
||||
[0, 1, 1, 0],
|
||||
[0, 1, 1, 1],
|
||||
|
||||
[1, 0, 0, 0],
|
||||
[1, 0, 0, 1],
|
||||
[1, 0, 1, 0],
|
||||
[1, 0, 1, 1],
|
||||
|
||||
[1, 1, 0, 0],
|
||||
[1, 1, 0, 1],
|
||||
[1, 1, 1, 0],
|
||||
[1, 1, 1, 1],
|
||||
])
|
||||
y = np.array([0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0])
|
||||
|
||||
model = Sequential([
|
||||
Input(shape=(3,)),
|
||||
Input(shape=(4,)),
|
||||
layers.Dense(3, activation="tanh"),
|
||||
layers.Dense(1, activation="sigmoid"),
|
||||
])
|
||||
|
||||
model.compile(optimizer=optimizers.Adam(learning_rate=0.05), loss="binary_crossentropy", metrics=["accuracy"])
|
||||
model.fit(x, y, epochs=100)
|
||||
model.fit(x, y, epochs=200)
|
||||
|
||||
loss, accuracy = model.evaluate(x, y)
|
||||
print(f"Loss: {loss}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user