赞
踩
神经网络通过不同的架构设置,来完成不同的任务,比如我们看到一半的逻辑与运算:
x
1
A
N
D
x
2
=
{
1
i
f
x
1
=
1
a
n
d
x
2
=
1
0
o
t
h
e
r
w
i
s
e
x_1\ AND\ x_2=
可以发现,逻辑运算可以转换为一个01分类问题。在sigmoid函数中:
g
(
4
)
≈
1
g(4)≈1
g(4)≈1
g
(
−
4
)
≈
0
g(−4)≈0
g(−4)≈0
因此,我们采用感知器神经网络:
[
x
0
x
1
x
2
]
→
[
g
(
z
(
2
)
)
]
→
h
Θ
(
x
)
\left[
并令:
Θ
(
1
)
=
[
−
30
20
20
]
\Theta^{(1)}=\left[-30\quad 20 \quad 20\right]
Θ(1)=[−302020]
生成的神经网络如下图所示:
得到的逻辑运算结果:
h
Θ
(
x
)
=
g
(
−
30
+
20
x
1
+
20
x
2
)
h_\Theta(x) = g(-30+20x_1+20x_2)
hΘ(x)=g(−30+20x1+20x2)
x
1
=
0
a
n
d
x
2
=
0
t
h
e
n
g
(
−
30
)
≈
0
x_1 = 0\ and\ x_2=0\ then\ g(-30)\approx 0
x1=0 and x2=0 then g(−30)≈0
x
1
=
0
a
n
d
x
2
=
1
t
h
e
n
g
(
−
10
)
≈
0
x_1 = 0\ and\ x_2=1\ then\ g(-10)\approx 0
x1=0 and x2=1 then g(−10)≈0
x
1
=
1
a
n
d
x
2
=
0
t
h
e
n
g
(
−
10
)
≈
0
x_1 = 1\ and\ x_2=0\ then\ g(-10)\approx 0
x1=1 and x2=0 then g(−10)≈0
x
1
=
1
a
n
d
x
2
=
1
t
h
e
n
g
(
10
)
≈
0
x_1 = 1\ and\ x_2=1\ then\ g(10)\approx 0
x1=1 and x2=1 then g(10)≈0
当然,这是手动进行定义的参数,我们也可以初始化如下样本对神经网络进行训练:
X
=
[
0
0
0
1
0
0
0
1
0
0
0
1
]
X=\left[
代码及实现可以参看程序示例。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。