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

6 ビュー (過去 30 日間)
Eulalie Boucher
Eulalie Boucher 2020 年 6 月 8 日
回答済み: Joseph Williams 2021 年 2 月 25 日
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];

回答 (2 件)

Divya Gaddipati
Divya Gaddipati 2020 年 6 月 16 日
Try using
net = trainNetwork(TB_train, TS_train, Layers, options);

Joseph Williams
Joseph Williams 2021 年 2 月 25 日
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!

Community Treasure Hunt

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

Start Hunting!

Translated by