help error CNN The output of layer 6 is incompatible with the input expected by layer 7.

1 Ansicht (letzte 30 Tage)
hi:
I am using MatLab R2017b in Win 10 64 bits
Greetings, can anybody help me with this code
Code:
% Define a CNN architecture
conv1 = convolution2dLayer(200,96,'Padding',2,'BiasLearnRateFactor',2);
conv1.Weights = gpuArray(single(randn([200 200 3 96])*0.0001));
fc1 = fullyConnectedLayer(225,'BiasLearnRateFactor',2);
fc1.Weights = gpuArray(single(randn([225 1130])*0.1));
fc2 = fullyConnectedLayer(10,'BiasLearnRateFactor',2);
fc2.Weights = gpuArray(single(randn([10 225])*0.1));
layers = [ ...
imageInputLayer([480 720 3]);
conv1;
maxPooling2dLayer(3,'Stride',2);
reluLayer();
convolution2dLayer(100,256,'Padding',2,'BiasLearnRateFactor',2);
reluLayer();
averagePooling2dLayer(85,'Stride',2);
convolution2dLayer(75,384,'Padding',2,'BiasLearnRateFactor',2);
reluLa yer();
averagePooling2dLayer(3,'Stride',2);
fc1;
reluLayer();
fc2;
softmaxLayer()
classificationLayer()
];
% Define the training options.
opts = trainingOptions('sgdm', ...
'InitialLearnRate', 0.001, ...
'LearnRateSchedule', 'piecewise', ...
'LearnRateDropFactor', 0.1, ...
'LearnRateDropPeriod', 8, ...
'L2Regularization', 0.004, ...
'MaxEpochs', 10, ...
'MiniBatchSize', 100, ...
'Verbose', true);
%Training the CNN
[net, info] = trainNetwork(XTrain, TTrain, layers, opts);
the error is:
" Error using trainNetwork (line 140)
The output of layer 6 is incompatible with the input expected by layer 7.
Error in CNN2 (line 87)
[net, info] = trainNetwork(XTrain, TTrain, layers, opts);
Caused by:
Error using nnet.internal.cnn.layer.util.inferParameters>iInferSize (line 86)
The output of layer 6 is incompatible with the input expected by layer 7.
"
The error is when run the code: trainNetwork
thks in advanced for help
Best regarts
Angel lerma

Antworten (1)

Joss Knight
Joss Knight am 2 Jun. 2018
I ran the Network Analyzer on your network:
analyzeNetwork(layers)
The resulting report told me that the activations input to your average pooling layer 7 are too small for a pooling window of 85-by-85 (see attached).
Did you really mean to make an average pooling layer with such a large window? because that would be unusual. Actually, it's unusual that you wanted a 200-by-200 convolution kernel followed by a 100-by-100 kernel, since these are almost the size of the original images.

Produkte


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by