Error using trainNetwork - Number of observations in X and Y disagree.

4 visualizaciones (últimos 30 días)
I want to build a cnn where my input is 1000 images of size 20 x 20 x 110 and output is 1000 images of size 20 x 20.
Therefore I have
net = trainNetwork(TB_train(:,:,:,:),TS_train(:,:,:),Layers,options); and I get an error 'Number of observations in X and Y disagree'. I don't understand as both of my matrices have 1000 images.
My cnn has these layers:
Layers = [imageInputLayer([20 20 110],'Normalization','none') %,'Weights',W,'Bias',B)
convolution2dLayer(3,128,'Padding','same')%,'Weights',W,'Bias',B)
batchNormalizationLayer
reluLayer
convolution2dLayer(1,64,'Padding','same')%,'Weights',W,'Bias',B)
batchNormalizationLayer
reluLayer
convolution2dLayer(1,32,'Padding','same')%,'Weights',W,'Bias',B)
batchNormalizationLayer
reluLayer
convolution2dLayer(1,16,'Padding','same')%,'Weights',W,'Bias',B)
batchNormalizationLayer
reluLayer
convolution2dLayer(1,1,'Padding','same')%,'Weights',W,'Bias',B)
batchNormalizationLayer
reluLayer
regressionLayer];

Respuestas (2)

Divya Gaddipati
Divya Gaddipati el 16 de Jun. de 2020
Try using
net = trainNetwork(TB_train, TS_train, Layers, options);

Joseph Williams
Joseph Williams el 25 de Feb. de 2021
Hello, I know this is an old question, but I am having a very similar difficulty, except with 3D images. I have 4000 (4 x 256 x 4) 3-channel images and want to create 4000 (4 x 256 x 4) 1-channel images.
I have a very similar architecture to yours and using analyzeNetwork(layers) shows that the layer before regression puts in the right size (for both our networks).
What was your solution to generate 1000 images of size 20 x 20? it may be my solution as well.
Thanks!

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by