Error using trainNetwork, output size of last layer does not match response size
1 次查看(过去 30 天)
显示 更早的评论
I am currently reworking the tutorial for Train Convolutional Neural Network for Regression. https://www.mathworks.com/help/deeplearning/ug/train-a-convolutional-neural-network-for-regression.html
In my application, I have 11x11pixel images and 16 channels. I am attempting to adjust the code from the example problem above and am getting an error when using the trainNetwork() function. It says:
Error using trainNetwork
Invalid training data. The output size ([1 1 26013]) of the last layer does not
match the response size ([1 1 26103]).
I'm a bit confused as to why this is happening, both those dimensions seems to match. I've attached my code for reference, its nearly identical to the example code in the tutorial referenced above except for a few adjustments to accomodate my data. Ideally, I would like a single corrected output for each input image. Any help would be greatly appreciated! Thanks in advance.
0 个评论
回答(1 个)
Animesh Gupta
2022-10-11
Hello,
It is my understanding that you are encountering size related error while training neural network.
Due to non-availability of actual data, it is difficult to get the root cause of the error. But I suspect the potential cause of this error is the reshaping of x_train at line 98.
The input size to the neural network model is defined as [11 11 16] in line 49.
But, at line 98, the training data is reshaped to [11 11 16 26103]. It will be read as "11 images of size 11 X 16 with 26103 channels" which is not desired.
Redefining the line 98 as following should fix this error.
X = reshape(x_train, [26103, 11, 11, 16]);
I hope it helps.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!