commit ea3668ea54901575cd226c4b3f6848294d22581a Author: rhinemann Date: Fri Sep 12 18:34:33 2025 +0300 lab 1 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/code.iml b/.idea/code.iml new file mode 100644 index 0000000..77e442c --- /dev/null +++ b/.idea/code.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d5b5c1c --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..23968dc --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/lab_1.py b/lab_1.py new file mode 100644 index 0000000..3a04dec --- /dev/null +++ b/lab_1.py @@ -0,0 +1,22 @@ +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]) + +model = Sequential([ + Input(shape=(3,)), + 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) + +loss, accuracy = model.evaluate(x, y) +print(f"Loss: {loss}") +print(f"Accuracy: {accuracy}") + +prediction = model.predict(x) +for inp, pred in zip(x, prediction): + print(inp, round(pred[0])) \ No newline at end of file