필터 지우기
필터 지우기

Adapting 1D CNN

조회 수: 13 (최근 30일)
Fernando Meneses
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...

채택된 답변

Mahesh Taparia
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!
  댓글 수: 1
Fernando Meneses
Fernando Meneses 2021년 7월 30일
Thank you! Removing the maxpooling layer worked.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by