【读书1】【2017】MATLAB与深度学习——批处理方法的实现(1)

本文探讨了批处理方法与随机梯度下降(SGD)在神经网络训练中的不同。批处理方法通过累积所有训练数据的权重更新并使用平均值一次性调整权重,而SGD则立即使用每个数据点的权重更新。批处理方法降低了训练过程对数据的敏感度,但可能需要更多的训练次数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

该代码不是使用每个训练数据点的权值更新dW,并立即训练神经网络。

This code does not immediately train theneural network with the weight update, dW, of the individual training datapoints.

而是将所有训练数据的权值更新累加得到dWsum,然后使用平均权值更新dWavg来一次性调节权值。

It adds the individual weight updates ofthe entire training data to dWsum and adjusts the weight just once using theaverage, dWavg.

这是批处理方法与SGD方法之间最基本的不同之处。

This is the fundamental difference thatseparates this method from the SGD method.

批处理方法中运用的平均特性使得训练过程相对于训练数据的敏感程度较低。

The averaging feature of the batch methodallows the training to be less sensitive to the training data.

回顾一下式2.6中的权值更新方法。

Recall that Equation 2.6 yields the weightupdate.

当你使用以上代码深入学习时,将会很容易理解该表达式的含义。

It will be much easier to understand thisequation when you look into it using the previous code.

为方便阅读,这里将式2.6再次撰写如下。

Equation 2.6 is shown here again, for yourconvenience.

在这里插入图片描述

下面的程序列表给出了测试函数DeltaBatch的MATLAB文件TestDeltaBatch.m。

The following program listing shows theTestDeltaBatch.m file that tests the function DeltaBatch.

该文件调用了DeltaBatch函数,训练神经网络40000次。

This program calls in the functionDeltaBatch and trains the neural network 40,000 times.

将所有的训练数据输入到神经网络中,并显示出结果。

All the training data is fed into thetrained neural network, and the output is displayed.

对比训练结果与训练数据的正确输出,从而验证训练的有效性。

Check the output and correct output fromthe training data to verify the adequacy of the training.

clear all
X = [ 0 0 1;
0 1 1;
1 0 1;
1 1 1;
];
D = [ 0 0 1 1 ];
W = 2*rand(1, 3) - 1;
for epoch = 1:40000

W =DeltaBatch(W, X, D);
end

N = 4;
for k = 1:N

x = X(k, ?’;

v = W*x;

y = Sigmoid(v)
end

接下来,执行以上代码,将在屏幕上看到以下的输出结果。

Next, execute this code, and you will seethe following values on your screen.

神经网络的训练输出与正确输出D非常相似。

The output is very similar to the correctoutput, D.

这也证明了该神经网络得到了正确的训练。

This verifies that the neural network hasbeen properly trained.

在这里插入图片描述

由于这个测试程序与TestDeltaSGD.m文件几乎相同,因此我们不再进行详细解释。

As this test program is almost identical tothe TestDeltaSGD.m file, we will skip the detailed explanation.

该方法有趣的地方是它训练了神经网络40000次。

An interesting point about this method isthat it trained the neural network 40,000 times.

回忆一下,SGD方法只进行了10000次训练。

Recall that the SGD method performed only10,000 trainings.

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值