-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy path3FVe.py
69 lines (49 loc) · 1.51 KB
/
3FVe.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#techgym7-3-A-2
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
# x、y座標(-1から1まで0.1刻み)
ar_min = -1.0
ar_max = 1.0
notch = 0.1
X = np.arange(ar_min, ar_max, notch)
Y = np.arange(ar_min, ar_max, notch)
#グリッド数
grid_num = int((abs(ar_min) + abs(ar_max)) / notch)
#出力を格納するグリッド
Z = np.zeros((grid_num,grid_num))
#シグモイド関数
def sigmoid_function(x):
return 1 / ( 1 + np.exp(-x))
############################################################
def layer3_neuron(wim1,wim2,wim3,wim4,wmo1,wmo2,bim1,bim2,bmo1):
# 重み
w_im =
w_mo =
#バイアス
b_im =
b_mo =
#中間層(シグモイド関数)
def middle_layer_s(x, w, b):
return sigmoid_function(u)
#出力層(恒等関数)
def output_layer(x, w, b):
return u
#グリッドの各マスでニューラルネットワークの演算
for i in range(grid_num):
for j in range(grid_num):
#順伝播
inp =
mid =
out =
#グリッドに出力を格納
Z[j][i] = out[0]
#表示
plt.imshow(Z, "gray", vmin = 0.0, vmax = 1.0)
plt.colorbar()
plt.show()
#重みとバイアスを変更
layer3_neuron(-5,-5, 5,-5, 1,-1, 0, 0, 0)
layer3_neuron( 4, 4, 4, 4,-1, 1, 3,-3, 1)
layer3_neuron(-4, 4,-4,-4, 1,-1, 3,-3, 0)
layer3_neuron(-2,-4,-1,-1, 0,-1, 2, 0,0.7)