input size mismatch error at crop layer,please help me to resolve this error

1 次查看(过去 30 天)
layers = [
imageInputLayer([500 500 3],'Name','image');
convolution2dLayer(3,64,'padding',100,'Name','conv1_1');
reluLayer('Name','relu1_1');
convolution2dLayer(3,64,'Padding',1,'Name','conv1_2');
reluLayer('Name','relu1_2');
%after convolution layer image size=[64,698,698]
maxPooling2dLayer(2,'Stride',2,'Name','pool1');
%after 1st pooling layer image size=[64,349,349]
convolution2dLayer(3,128,'Padding',1,'Name','conv2_1');
reluLayer('Name','relu2_1');
convolution2dLayer(3,128,'Padding',1,'Name','conv2_2');
reluLayer('Name','relu2_2');
%after convolution layer image size=[128,349,349]
maxPooling2dLayer(2,'Stride',2,'Name','pool2');
%after 1st pooling layer image size=[128,175,175]
convolution2dLayer(3,256,'Padding',1,'Name','conv3_1');
reluLayer('Name','relu3_1');
convolution2dLayer(3,256,'Padding',1,'Name','conv3_2');
reluLayer('Name','relu3_2');
convolution2dLayer(3,256,'Padding',1,'Name','conv3_3');
reluLayer('Name','relu3_3');
%after convolution layer image size=[256,175,175]
maxPooling2dLayer(2,'Stride',2,'Name','pool3');
%after 1st pooling layer image size=[256,88,88]
convolution2dLayer(3,512,'Padding',1,'Name','conv4_1');
reluLayer('Name','relu4_1');
convolution2dLayer(3,512,'Padding',1,'Name','conv4_2');
reluLayer('Name','relu4_2');
convolution2dLayer(3,512,'Padding',1,'Name','conv4_3');
reluLayer('Name','relu4_3');
%after convolution layer image size=[512,88,88]
maxPooling2dLayer(2,'Stride',2,'Name','pool4');
%after 1st pooling layer image size=[512,44,44]
convolution2dLayer(3,256,'Padding',1,'Name','conv5_1');
reluLayer('Name','relu5_1');
convolution2dLayer(3,256,'Padding',1,'Name','conv5_2');
reluLayer('Name','relu5_2');
convolution2dLayer(3,256,'Padding',1,'Name','conv5_3');
reluLayer('Name','relu5_3');
%after convolution layer image size=[512,44,44]
maxPooling2dLayer(2,'Stride',2,'Name','pool5');
%after 1st pooling layer image size=[512,22,22]
convolution2dLayer(7,4096,'padding',0,'Name','fc6');
reluLayer('Name','relu6');
dropoutLayer(0.5,'Name','drop_6');
convolution2dLayer(1,4096,'padding',0,'Name','fc7');
reluLayer('Name','relu7');
dropoutLayer(0.5,'Name','drop_7');
convolution2dLayer(1,21,'padding',0,'Name','score_fr');
transposedConv2dLayer(4,21,'Stride',2,'Name','score2');
crop2dLayer('centercrop','Name','crop_pool4');
additionLayer(2,'Name','add_1');
transposedConv2dLayer(4,21,'Stride',2,'Name','score4');
crop2dLayer('centercrop','Name','crop_pool3');
additionLayer(2,'Name','add_2');
transposedConv2dLayer(16,21,'Stride',8,'Name','upsample');
crop2dLayer('centercrop','Name','crop_score');
];
lgraph = layerGraph(layers);
score_pool4=convolution2dLayer(1,21,'padding',0,'Name','score_pool4');
lgraph = addLayers(lgraph,score_pool4);
lgraph = connectLayers(lgraph,'pool4','score_pool4');
lgraph = connectLayers(lgraph,'score_pool4','crop_pool4/ref');
score_pool3=convolution2dLayer(1,21,'Name','score_pool3');
lgraph = addLayers(lgraph,score_pool3);
lgraph = connectLayers(lgraph,'pool3','score_pool3');
lgraph = connectLayers(lgraph,'score_pool3','crop_pool3/ref');
lgraph = connectLayers(lgraph,'score2','add_1/in2');
lgraph = connectLayers(lgraph,'image','crop_score/ref');
plot(lgraph);
analyzeNetwork(lgraph)

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by