- Refer to the ‘Properties’ section to understand how to correctly set up the max pooling layer: https://www.mathworks.com/help/deeplearning/ref/nnet.cnn.layer.maxpooling2dlayer.html
- Refer to the ‘Algorithms’ section to understand the input and corresponding output sizes of the 2D convolutional layer: https://www.mathworks.com/help/deeplearning/ref/nnet.cnn.layer.convolution2dlayer.html
I face this error "Caused by: Layer 17: Input size mismatch. Size of input to this layer is different from the expected input size. Inputs to this layer: from layer 16 (1×1×2 output) "
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
layers = [
imageInputLayer([8 1 1])
convolution2dLayer([4 1],8,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer([2 1],'Stride',2)
convolution2dLayer([4 1],16,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer([2 1],'Stride',2)
convolution2dLayer([4 1],4,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer([2 1],'Stride',2)
convolution2dLayer([4 1],2,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer([2 1],'Stride',2)
convolution2dLayer([4 1],1,'Padding','same')
batchNormalizationLayer
reluLayer
fullyConnectedLayer(2)
softmaxLayer
classificationLayer];
options = trainingOptions('sgdm',...
'ExecutionEnvironment', 'cpu',...
'InitialLearnRate',0.005,...
'MaxEpochs',30, ...
'Verbose',false,...
'ValidationData',{XValidation,YValidation}, ...
'ValidationFrequency',10, ...
'MiniBatchSize',30, ...
'Plots','training-progress');
net = trainNetwork(Xtrain,Ytrain,layers,options); %
0 commentaires
Réponses (1)
Garmit Pant
le 12 Juil 2024
Hello Saddam
The error you have encountered is due to a size mismatch between the expected input size of the fourth max pooling layer and the actual size of the input of the layer.
On analysing the network using “analyzeNetwork” function, we can see that the output size after layer 14, ‘conv_4’, is 1x1x2x1. The size of the pool operation on layer 17, ‘maxpool_4’, is 2x1. Since the size of the pooling dimensions should be larger or equal to the pool size, the error you are encountering is occurring. You can use the following code snippet to check your network:
analyzeNetwork(layers)
Output:
This can be rectified by removing the fourth max pooling layer.
For further understanding, kindly refer to the following MathWorks Documentation:
I hope you find the above explanation and suggestions useful!
0 commentaires
Voir également
Catégories
En savoir plus sur Deep Learning Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!