Actual numeric convolution example with strides and padding using convolution2dlayer command

5 ビュー (過去 30 日間)
CHENG FEI PHUNG
CHENG FEI PHUNG 2020 年 3 月 9 日
編集済み: Dinesh Yadav 2020 年 3 月 12 日
For convolution2dlayer command , how do I simulate an actual numeric example of convolution with strides and padding ?

回答 (1 件)

Dinesh Yadav
Dinesh Yadav 2020 年 3 月 12 日
編集済み: Dinesh Yadav 2020 年 3 月 12 日
Hi, go through the following code
input = randi(10,10,10); %creating a random input 2-d array
layer=imageInputLayer([10 10],'Name','Input','Normalization','none'); % defining input layer of network
layer2 = convolution2dLayer(3,1,'Padding',[1 1 1 1],'Stride',2,'WeightsInitializer',...
@(sz) rand(sz) * 0.0001,'BiasInitializer', @(sz) rand(sz) * 0.0001,'Name','con'); % defining convolution layer of network
layer1=[layer layer2];
lg=layerGraph(layer1);
net=dlnetwork(lg);
out=predict(net,dlarray(input,'SSC'))
As input matrix in 10x10 and convolution is with padding 1 and stride 2 output matrix is 5x5.
Hope it helps.

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by