【读书1】【2017】MATLAB与深度学习——示例:多元分类(3)

例如,数字1的图像编码矩阵如图4-14所示。

For example, the image of the number 1 is encoded in the matrixshown in Figure 4-14.

在这里插入图片描述
图4-14数字1的图像编码矩阵Theimage of the number 1 is encoded in the matrix

变量D中的数据为正确输出。

In contrast, the variable D contains thecorrect output.

例如,第一个输入数据的正确输出(即图像1)位于变量D的第一行,对每个输出节点采用一元热键的形式编码。

For example, the correct output to thefirst input data, i.e. the image of 1, is located on the first row of thevariable D, which is constructed using the one-hot encoding method for each ofthe five output nodes.

执行TestMultiClass.m文件,根据训练输出与D之间的误差来判断神经网络是否被正确训练。

Execute the TestMultiClass.m file, and youwill see that the neural network has been properly trained in terms of thedifference between the output and D.

到目前为止,我们只对训练数据进行了神经网络的验证。

So far, we have verified the neural networkfor only the training data.

然而,实际数据并不一定反映训练数据。

However, the practical data does notnecessarily reflect the training data.

这一事实,正如我们先前所讨论的,是机器学习的基本问题,并且需要解决。

This fact, as we previously discussed, isthe fundamental problem of Machine Learning and needs to solve.

让我们用一个简单的实验来检验神经网络。

Let’s check our neural network with asimple experiment.

考虑图4-15中显示的轻微污染的图像,观察神经网络如何对它们做出响应(判断)。

Consider the slightly contaminated imagesshown in Figure 4-15 and watch how the neural network responds to them.

在这里插入图片描述
图4-15 让我们看看神经网络是如何对这些污染图像做出反应的Let’s seehow the neural network responds to these contaminated images

下面显示了RealMultiClass.m文件的程序清单,它将图4-15所示的图像进行分类。

The following listing shows theRealMultiClass.m file, which classifies the images shown in Figure 4-15.

该程序从TestMultiClass命令的执行开始,进行神经网络的训练。

This program starts with the execution ofthe TestMultiClass command and trains the neural network.

该训练过程产生权重矩阵W1和W2。

This process yields the weight matrices W1and W2.

clear all

TestMultiClass; % 产生权重矩阵W1, W2

X = zeros(5, 5, 5);

X(:, :, 1) = [0 0 1 1 0;

      0 0 1 1 0;

      0 1 0 1 0;

      0 0 0 1 0;

      0 1 1 1 0

    ];

X(:, :, 2) = [1 1 1 1 0;

      0 0 0 0 1;

      0 1 1 1 0;

      1 0 0 0 1;

      1 1 1 1 1

    ];

X(:, :, 3) = [1 1 1 1 0;

      0 0 0 0 1;

      0 1 1 1 0;

      1 0 0 0 1;

      1 1 1 1 0

    ];

X(:, :, 4) = [0 1 1 1 0;

      0 1 0 0 0;

      0 1 1 1 0;

      0 0 0 1 0;

      0 1 1 1 0

    ];

X(:, :, 5) = [0 1 1 1 1;

      0 1 0 0 0;

      0 1 1 1 0;

      0 0 0 1 0;

      1 1 1 1 0

    ];

N = 5; % 推断

for k = 1:N

   x= reshape(X(:, :, k), 25, 1);

   v1 = W1*x;

   y1 = Sigmoid(v1);

   v = W2*y1;

   y = Softmax(v)

end

此代码与TestMultiClass.m文件的代码相同,只是它具有不同的输入X,并且不包括训练过程。

This code is identical to that of theTestMultiClass.m file, except that it has a different input X and does notinclude the training process.

该程序的执行产生五个被污染图像的响应输出。

Execution of this program produces theoutput of the five contaminated images.

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

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

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值