该过程如图6-19所示。
The process is illustrated in Figure 6-19.
图6-19 图像经过卷积和池化层的处理过程How the image isprocessed while it passes through the convolution and pooling layers
通过卷积层和池化层后的最终结果是与卷积滤波器数量一样多的较小的图像;ConvNet将输入图像转换为许多小尺度的特征映射。
The final result after passing theconvolution and pooling layers is as many smaller images as the number of theconvolution filters; ConvNet converts the input image into the many smallfeature maps.
现在,我们将看到输入图像如何在每一层神经网络中进化。
Now, we will see how the image actuallyevolves at each layer of ConvNet.
通过执行TestMnistConv.m文件,然后是PlotFeatures.m文件,屏幕将显示出五幅图像。
By executing the TestMnistConv.m file,followed by the PlotFeatures.m file, the screen will display the five images.
以下为PlotFeatures.m文件的代码清单。
The following listing is in the PlotFeatures.mfile.
clear all
load(‘MnistConv.mat’)
k = 2;
x = X(:, :, k); %Input, 28x28
y1 = Conv(x, W1);% Convolution, 20x20x20
y2 = ReLU(y1); %
y3 = Pool(y2); %Pool, 10x10x20
y4 = reshape(y3,[], 1); % 2000
v5 = W5*y4; %ReLU, 360
y5 = ReLU(v5); %
v = Wo*y5; % Softmax, 10
y = Softmax(v); %
figure;
display_network(x(?);
title(‘Input Image’)
convFilters = zeros(9*9, 20);
for i = 1:20
filter= W1(:, :, i);
convFilters(:,i) = filter(:);
end
figure
display_network(convFilters);
title(‘Convolution Filters’)
fList = zeros(20*20, 20);
for i = 1:20
feature= y1(:, :, i);
fList(:,i) = feature(:);
end
figure
display_network(fList);
title(‘Features [Convolution]’)
fList = zeros(20*20, 20);
for i = 1:20
feature= y2(:, :, i);
fList(:,i) = feature(:);
end
figure
display_network(fList);
title(‘Features [Convolution + ReLU]’)
fList = zeros(10*10, 20);
for i = 1:20
feature= y3(:, :, i);
fList(:,i) = feature(:);
end
figure
display_network(fList);
title(‘Features [Convolution + ReLU +MeanPool]’)
该代码将测试数据的第二幅图像(k = 2)输入到神经网络,并显示最后的输出结果。
The code enters the second image (k = 2) ofthe test data into the neural network and displays the results of all thesteps.
函数display_network将图像矩阵显示到屏幕上,该函数与TestMnistConv.m 文件中的loadMNISTImages和loadMNISTLabels函数都来自于相同的网络下载地址。
The display of the matrix on the screen isperformed by the function display_network, which is originally from the sameresource where the loadMNISTImages and loadMNISTLabels of the TestMnistConv.mfile are from.
——本文译自Phil Kim所著的《Matlab Deep Learning》
更多精彩文章请关注微信号: