Adieva-15 commited on
Commit
a343a09
·
1 Parent(s): 7d1c38d

first commit

Browse files
Files changed (3) hide show
  1. app.py +15 -4
  2. function.py +24 -0
  3. requirements.txt +3 -1
app.py CHANGED
@@ -1,7 +1,18 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello" + name
 
5
 
6
- demo = gr.Interface(fn=greet, inputs='text', outputs='text')
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from function import go
3
 
4
+ house = 1
5
+ rock = 0
6
+ attr = 1
7
 
8
+ def greet():
9
+ return "Hello"
10
+
11
+ def main():
12
+ res = go(house, rock, attr)
13
+ if res == 1:
14
+ print("Ты мне нравишься")
15
+ else:
16
+ print("Созвонимся")
17
+ demo = gr.Interface(fn=greet, inputs='text', outputs='text')
18
+ demo.launch(share=True)
function.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+
3
+ def act(x):
4
+ return 0 if x < 0.5 else 1
5
+
6
+ def go(house, rock, attr):
7
+ x = np.array([house, rock, attr])
8
+ w11 = [0.3, 0.3, 0]
9
+ w12 = [0.4, -0.5, 1]
10
+ weight1 = np.array([w11, w12]) # матрица 2x3
11
+ weight2 = np.array([-1, 1]) # вектор 1х2
12
+
13
+ sum_hidden = np.dot(weight1, x) # вычисляем сумму на входах нейронов скрытого слоя
14
+ print("Значения сумм на нейронах скрытого слоя: "+str(sum_hidden))
15
+
16
+ out_hidden = np.array([act(x) for x in sum_hidden])
17
+ print("Значения на выходах нейронов скрытого слоя: "+str(out_hidden))
18
+
19
+ sum_end = np.dot(weight2, out_hidden)
20
+ y = act(sum_end)
21
+ print("Выходное значение НС: "+str(y))
22
+
23
+ return y
24
+
requirements.txt CHANGED
@@ -1 +1,3 @@
1
- gradio
 
 
 
1
+ gradio
2
+ numpy
3
+ matplotlib