error when using Cropping layer (Deep learning)

Hi, I have medical images and I have tried to implement this architecture described in(https://arxiv.org/pdf/1505.04597) but unfortunately I got this error message below, can you fix this problem please? I appreciate any help.

Error using trainNetwork (line 140)
Layer 27 is expected to have a different size.,/pre>

And this is the structure that I have implemented:

layers = [
imageInputLayer([572 572 3],'Name','input')
convolution2dLayer(3,64,'Padding',0,'Name','conv1_1')
reluLayer('Name','relu1_1')
convolution2dLayer(3,64,'Padding',0,'Name','conv1_2')
reluLayer('Name','relu1_2')
maxPooling2dLayer(2,'Stride',2,'Name','maxpool_1')
convolution2dLayer(3,128,'Padding',0,'Name','conv2_1')
reluLayer('Name','relu2_1')
convolution2dLayer(3,128,'Padding',0,'Name','conv2_2')
reluLayer('Name','relu2_2')
maxPooling2dLayer(2,'Stride',2,'Name','maxpool_2')
convolution2dLayer(3,256,'Padding',0,'Name','conv3_1')
reluLayer('Name','relu3_1')
convolution2dLayer(3,256,'Padding',0,'Name','conv3_2')
reluLayer('Name','relu3_2')
maxPooling2dLayer(2,'Stride',2,'Name','maxpool_3')
convolution2dLayer(3,512,'Padding',0,'Name','conv4_1')
reluLayer('Name','relu4_1')
convolution2dLayer(3,512,'Padding',0,'Name','conv4_2')
reluLayer('Name','relu4_2')
maxPooling2dLayer(2,'Stride',2,'Name','maxpool_4')
convolution2dLayer(3,1024,'Padding',0,'Name','conv5_1')
reluLayer('Name','relu5_1')
convolution2dLayer(3,1024,'Padding',0,'Name','conv5_2')
reluLayer('Name','relu5_2')
transposedConv2dLayer(4,1024,'Stride',2,'Cropping',1,'Name','upscore2')
additionLayer(2,'Name','add1')
convolution2dLayer(3,512,'Padding',0,'Name','conv6_1')
reluLayer('Name','relu6_1')
convolution2dLayer(3,512,'Padding',0,'Name','conv6_2')
reluLayer('Name','relu6_2')
transposedConv2dLayer(4,512,'Stride',2,'Cropping',1,'Name','upscore4')
additionLayer(2,'Name','add2')
convolution2dLayer(3,256,'Padding',0,'Name','conv7_1')
reluLayer('Name','relu7_1')
convolution2dLayer(3,256,'Padding',0,'Name','conv7_2')
reluLayer('Name','relu7_2')
transposedConv2dLayer(4,256,'Stride',2,'Cropping',1,'Name','upscore8')
additionLayer(2,'Name','add3')
convolution2dLayer(3,128,'Padding',0,'Name','conv8_1')
reluLayer('Name','relu8_1')
convolution2dLayer(3,128,'Padding',0,'Name','conv8_2')
reluLayer('Name','relu8_2')
transposedConv2dLayer(4,128,'Stride',2,'Cropping',1,'Name','upscore10')
additionLayer(2,'Name','add4')
convolution2dLayer(3,64,'Padding',0,'Name','conv9_1')
reluLayer('Name','relu9_1')
convolution2dLayer(3,64,'Padding',0,'Name','conv9_2')
reluLayer('Name','relu9_2')
convolution2dLayer(1,5,'Name','conv10')
softmaxLayer('Name','softmax')
classificationLayer('Name','classOutput')
];
lgraph = layerGraph(layers);
score_pool4c=crop2dLayer('centercrop','Name','score_pool4c') ;
lgraph = addLayers(lgraph,score_pool4c);
lgraph = connectLayers(lgraph,'relu4_2','score_pool4c/in');
lgraph = connectLayers(lgraph,'upscore2','score_pool4c/ref');
lgraph = connectLayers(lgraph,'score_pool4c','add1/in2');
score_pool3c=crop2dLayer('centercrop','Name','score_pool3c') ;
lgraph = addLayers(lgraph,score_pool3c);
lgraph = connectLayers(lgraph,'relu3_2','score_pool3c/in');
lgraph = connectLayers(lgraph,'upscore4','score_pool3c/ref');
lgraph = connectLayers(lgraph,'score_pool3c','add2/in2');
score_pool2c=crop2dLayer('centercrop','Name','score_pool2c') ;
lgraph = addLayers(lgraph,score_pool2c);
lgraph = connectLayers(lgraph,'relu2_2','score_pool2c/in');
lgraph = connectLayers(lgraph,'upscore8','score_pool2c/ref');
lgraph = connectLayers(lgraph,'score_pool2c','add3/in2');
score_pool1c=crop2dLayer('centercrop','Name','score_pool1c') ;
lgraph = addLayers(lgraph,score_pool1c);
lgraph = connectLayers(lgraph,'relu1_2','score_pool1c/in');
lgraph = connectLayers(lgraph,'upscore10','score_pool1c/ref');
lgraph = connectLayers(lgraph,'score_pool1c','add4/in2');
figure
plot(lgraph);

NOTE:-

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help , Finance Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

ayers = [ … imageInputLayer([572 572 1],’Name’,’input’) convolution2dLayer([3 3],64,’Padding’,[0 0 0 0],’Stride’,[1 1],’Name’,’conv_d0a-b’) reluLayer(‘Name’,’relu_d0b’) convolution2dLayer([3 3],64,’Padding’,[0 0 0 0],’Stride’,[1 1],’Name’,’conv_d0b-c’) reluLayer(‘Name’,’relu_d0c’) maxPooling2dLayer([2 2],’Stride’,[2 2],’Name’,’pool_d0c-1a’)

convolution2dLayer([3 3],128,'Padding',[0 0 0 0],'Stride',[1 1],'Name','conv_d1a-b')
reluLayer('Name','relu_d1b')
convolution2dLayer([3 3],128,'Padding',[0 0 0 0],'Stride',[1 1],'Name','conv_d1b-c')
reluLayer('Name','relu_d1c')
maxPooling2dLayer([2 2],'Stride',[2 2],'Name','pool_d1c-2a')
convolution2dLayer([3 3],256,'Padding',[0 0 0 0],'Stride',[1 1],'Name','conv_d2a-b')
reluLayer('Name','relu_d2b')
convolution2dLayer([3 3],256,'Padding',[0 0 0 0],'Stride',[1 1],'Name','conv_d2b-c')
reluLayer('Name','relu_d2c')
maxPooling2dLayer([2 2],'Stride',[2 2],'Name','pool_d2c-3a')
convolution2dLayer([3 3],512,'Padding',[0 0 0 0],'Stride',[1 1],'Name','conv_d3a-b')
reluLayer('Name','relu_d3b')
convolution2dLayer([3 3],512,'Padding',[0 0 0 0],'Stride',[1 1],'Name','conv_d3b-c')
reluLayer('Name','relu_d3c')
dropoutLayer(0.5,'Name','dropout_d3c')
maxPooling2dLayer([2 2],'Stride',[2 2],'Name','pool_d3c-4a')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
convolution2dLayer([3 3],1024,'Padding',[0 0 0 0],'Stride',[1 1],'Name','conv_d4a-b')
reluLayer('Name','relu_d4b')
convolution2dLayer([3 3],1024,'Padding',[0 0 0 0],'Stride',[1 1],'Name','conv_d4b-c')
reluLayer('Name','relu_d4c')
dropoutLayer(0.5,'Name','dropout

SEE COMPLETE ANSWER CLICK THE LINK

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Technical Source

Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.