Adapting 1D CNN
6 ビュー (過去 30 日間)
古いコメントを表示
Fernando Meneses
2021 年 7 月 26 日
コメント済み: Fernando Meneses
2021 年 7 月 30 日
Hello, I'm trying to adapt a 1D-CNN, which is originally described in https://arxiv.org/abs/1610.01683, to my own samples, which have the following format:
4 classes of signals, 30 samples per class, each sample is a one-dimensional array with 100 points.
From a previous post (https://www.mathworks.com/matlabcentral/answers/331164-convolutional-1d-net) I found the following architecture for the network:
inputLayer=imageInputLayer([1 6000]);
c1=convolution2dLayer([1 200],20,'stride',1);
p1=maxPooling2dLayer([1 20],'stride',10);
c2=convolution2dLayer([20 30],400,'numChannels',20);
p2=maxPooling2dLayer([1 10],'stride',[1 2]);
f1=fullyConnectedLayer(500);
f2=fullyConnectedLayer(500);
s1=softmaxLayer;
outputLayer=classificationLayer;
convnet=[inputLayer; c1; p1; c2; p2; f1; f2; s1;outputLayer]
opts = trainingOptions('sgdm');
convnet = trainNetwork(allData',labels,convnet,opts);
Output:
convnet =
9x1 Layer array with layers:
1 '' Image Input 1x6000x1 images with 'zerocenter' normalization
2 '' Convolution 20 1x200 convolutions with stride [1 1] and padding [0 0]
3 '' Max Pooling 1x20 max pooling with stride [10 10] and padding [0 0]
4 '' Convolution 400 20x30 convolutions with stride [1 1] and padding [0 0]
5 '' Max Pooling 1x10 max pooling with stride [1 2] and padding [0 0]
6 '' Fully Connected 500 fully connected layer
7 '' Fully Connected 500 fully connected layer
8 '' Softmax softmax
9 '' Classification Output cross-entropy
I changed some of the parameters to adapt the networks for my samples, namely:
inputLayer=imageInputLayer([1 100]); % [1 6000] replaced by [1 100]
c1=convolution2dLayer([1 20],20,'stride',1); % [1 200] replaced by [1 20]
p1=maxPooling2dLayer([1 20],'stride',10);
c2=convolution2dLayer([20 30],400,'numChannels',20);
p2=maxPooling2dLayer([1 10],'stride',[1 2]);
f1=fullyConnectedLayer(500);
f2=fullyConnectedLayer(500);
s1=softmaxLayer;
outputLayer=classificationLayer;
I tried to run this same network but I got an error regarding the dimensions of Layer 4:
Layer 4: Input size mismatch. Size of input to this layer is different from the expected
input size.
Inputs to this layer:
from layer 3 (output size 1×7×20)
Could you help me finding the appropiate dimensions for network's architecture? Thanks...
0 件のコメント
採用された回答
Mahesh Taparia
2021 年 7 月 30 日
Hi
Try to change the maxpooling operation,like make it with small window like [1 2] or you can remove max pooling operation as the input dimension is not that large. The error you are getting because of size mismatch between features and the hidden layer parameters.
Hope it will help!
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Image Data Workflows についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!