-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathlesson 1.py
33 lines (25 loc) · 1 KB
/
lesson 1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import numpy as np
def act(x):
return 0 if x < 0.5 else 1
def go(house, rock, attr):
x = np.array([house, rock, attr])
w11 = [0.3, 0.3, 0]
w12 = [0.4, -0.5, 1]
weight1 = np.array([w11, w12]) # матрица 2x3
weight2 = np.array([-1, 1]) # вектор 1х2
sum_hidden = np.dot(weight1, x) # вычисляем сумму на входах нейронов скрытого слоя
print("Значения сумм на нейронах скрытого слоя: "+str(sum_hidden))
out_hidden = np.array([act(x) for x in sum_hidden])
print("Значения на выходах нейронов скрытого слоя: "+str(out_hidden))
sum_end = np.dot(weight2, out_hidden)
y = act(sum_end)
print("Выходное значение НС: "+str(y))
return y
house = 1
rock = 0
attr = 1
res = go(house, rock, attr)
if res == 1:
print("Ты мне нравишься")
else:
print("Созвонимся")