- Input Size: 256*256*3
- Pool Size: 2*2
- Padding: 0
- Stride: 1
Invalid training data: The output size of the last layer does not match the response size
조회 수: 21 (최근 30일)
이전 댓글 표시
layers = [
imageInputLayer([256 256 1],"Name","imageinput")
convolution2dLayer([7 7],3,'Stride',1,"Name","conv1","Padding","same")
reluLayer("Name","relu1")
%batchNormalizationLayer("Name","batchnorm")
maxPooling2dLayer(2,'Name','maxPooling1', 'stride', 1)
convolution2dLayer([5 5],3,'Stride',1,"Name","conv2","Padding","same")
reluLayer("Name","relu2")
maxPooling2dLayer(2,'Name','maxPooling2', 'stride', 1)
convolution2dLayer([3 3],2,'Stride',1,"Name","conv3","Padding","same")
reluLayer("Name","relu3")
maxPooling2dLayer(2,'Name','maxPooling3', 'stride', 1)
softmaxLayer("Name","softmax")
pixelClassificationLayer("Name","pixel-class", )
];
Error using trainNetwork (line 165)
Invalid training data. The output size ([253 253 2]) of the last layer does not match the response size ([256 256 2]).
댓글 수: 0
채택된 답변
Jyothis Gireesh
2019년 9월 19일
This issue arises due to size mismatch between the ground truth and the network output and may be resolved by setting the “Padding’’ attribute of the “maxPooling2dLayer” appropriately.
In the above code, the stride value is set to 1 which is less than the pool layer size (2x2). This causes overlapping regions of the input to be processed by the pool layer. The output image size in this case is given by the following formula
(Input Size – Pool Size + 2*Padding)/Stride + 1.
For instance, consider the first pooling layer. Here
Here the output size will be 255*255*3.
Each subsequent pooling layer will reduce the height and width of the input by 1. After 3 maxpooling layers output will be of size (253*253*3).
By setting the ‘Padding’ attribute to [1 1], the size of the image remains same. Please make use of the following syntax to change the ‘Padding’
maxPooling2dLayer(2,'Name','maxPooling1', 'stride', 1, ’Padding’ ,[1 1])
Please refer to the following documentation link on maxpooling layer
댓글 수: 0
추가 답변 (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!