【读书1】【2017】MATLAB与深度学习——单层神经网络的局限性(1)

单层神经网络的局限性(Limitations of Single-Layer Neural Networks)

本节将给出单层神经网络演化到多层神经网络的重要原因。

This section presents the critical reasonthat the single-layer neural network had to evolve into a multi-layer neuralnetwork.

我们将通过一个特定的案例来说明这一点。

We will try to show this through aparticular case.

仍然考虑上一节讨论的相同的神经网络。

Consider the same neural network that wasdiscussed in the previous section.

它由三个输入节点和一个输出节点组成,并且输出节点的激活函数是一个sigmoid函数(图2-21)。

It consists of three input nodes and anoutput node, and the activation function of the output node is a sigmoidfunction (Figure 2-21).

在这里插入图片描述

图2-21 与上一节相同的神经网络Our same neural network

假设我们有四组训练数据点,如下所示。

Assume that we have four training datapoints, as shown here.

在这里插入图片描述

它与“示例:增量规则”部分的不同之处在于第二组和第四组的正确输出被交换,而输入保持不变。

It is different from that of the “Example:Delta Rule” section in that the second and fourth correct outputs are switchedwhile the inputs remain the same.

嗯,差异几乎不明显。

Well, the difference is barely noticeable.

这种差异并不应该会引起任何麻烦,对吧?

It shouldn’t cause any trouble, right?

现在我们将使用SGD对增量规则进行训练。

We will now train it with the delta ruleusing the SGD.

当我们考虑相同的神经网络时,我们可以使用“示例:增量规则”一节中的函数DeltaSGD来训练它。

As we are considering the same neuralnetwork, we can train it using the function DeltaSGD from the “Example: DeltaRule” section.

我们只是将该函数的命名修改为DeltaXOR。

We have to just change its name toDeltaXOR.

下面的程序清单显示了TestDeltaXOR.m文件的代码,用于测试DeltaXOR函数。

The following program listing shows theTestDeltaXOR.m file, which tests the DeltaXOR function.

该程序与“示例:增量规则”一节中的TestDeltaSGD.m文件相同,只是它对期望的输出D具有不同的值,并且它调用DeltaXOR函数而不是DeltaSGD。

This program is identical to theTestDeltaSGD.m file from the “Example: Delta Rule” section, except that it hasdifferent values for D, and it calls the DeltaXOR function instead of DeltaSGD.

clear all
X = [ 0 0 1;
0 1 1;
1 0 1;
1 1 1;
];
D = [ 0 1 1 0];

W = 2*rand(1, 3) - 1;

for epoch = 1:40000 % train

W = DeltaXOR(W,X, D);

end

N = 4; %inference
for k = 1:N

x = X(k, ?’;

v = W*x;

y = Sigmoid(v)
end

当我们运行以上代码时,电脑屏幕将显示以下值,这些值由训练后的神经网络对应于训练数据的输出组成。

When we run the code, the screen will showthe following values, which consist of the output from the trained neuralnetwork corresponding to the training data.

——本文译自Phil Kim所著的《Matlab Deep Learning》

更多精彩文章请关注微信号:在这里插入图片描述

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值