Why do i receive Uncoonected input?

3 views (last 30 days)
Hind Haboubi
Hind Haboubi on 30 Apr 2021
Answered: Gayathri on 24 Dec 2024 at 4:32
netWidth = 16;
layers = [
imageInputLayer([224 224 3],'Name','input')
convolution2dLayer(3,netWidth,'Padding','same','Name','convInp')
batchNormalizationLayer('Name','BNInp')
reluLayer('Name','reluInp')
convolutionalUnit(netWidth,1,'S1U1')
additionLayer(2,'Name','add11')
reluLayer('Name','relu11')
convolutionalUnit(netWidth,1,'S1U2')
additionLayer(2,'Name','add12')
reluLayer('Name','relu12')
convolutionalUnit(2*netWidth,2,'S2U1')
additionLayer(2,'Name','add21')
reluLayer('Name','relu21')
convolutionalUnit(2*netWidth,1,'S2U2')
additionLayer(2,'Name','add22')
reluLayer('Name','relu22')
convolutionalUnit(4*netWidth,2,'S3U1')
additionLayer(2,'Name','add31')
reluLayer('Name','relu31')
convolutionalUnit(4*netWidth,1,'S3U2')
additionLayer(2,'Name','add32')
reluLayer('Name','relu32')
averagePooling2dLayer(8,'Name','globalPool')
fullyConnectedLayer(2,'Name','fcFinal')
softmaxLayer('Name','softmax')
classificationLayer('Name','classoutput')
];
lgraph = layerGraph(layers);
lgraph = connectLayers(lgraph,'reluInp','add11/in2');
lgraph = connectLayers(lgraph,'relu11','add12/in2');
skip1 = [
convolution2dLayer(1,2*netWidth,'Stride',2,'Name','skipConv1')
batchNormalizationLayer('Name','skipBN1')];
lgraph = addLayers(lgraph,skip1);
lgraph = connectLayers(lgraph,'relu12','skipConv1');
lgraph = connectLayers(lgraph,'skipBN1','add21/in2');
lgraph = connectLayers(lgraph,'relu21','add22/in2');
skip2 = [
convolution2dLayer(1,4*netWidth,'Stride',2,'Name','skipConv2')
batchNormalizationLayer('Name','skipBN2')];
lgraph = addLayers(lgraph,skip2);
lgraph = connectLayers(lgraph,'relu22','skipConv2');
lgraph = connectLayers(lgraph,'skipBN2','add31/in2');
lgraph = connectLayers(lgraph,'relu31','add32/in2');
options = trainingOptions('sgdm', 'MiniBatchSize',128,'MaxEpochs',10,'InitialLearnRate',1e-4,'ExecutionEnvironment','parallel');
%[trainedNet1,traininfo] = trainNetwork(trainData,lgraph,options);
class = trainedNet1;
convnet= trainNetwork(trainData,layers,options);
Hello Community, please I have a problem with this code, when i run it they said:
Error in NOUVEAU (line 107)
convnet= trainNetwork(trainData,layers,options);
Caused by:
Layer 'add11': Unconnected input. Each layer input must be connected to the output of another layer.
Detected unconnected inputs:
input 'in2'
Layer 'add12': Unconnected input. Each layer input must be connected to the output of another layer.
Detected unconnected inputs:
input 'in2'
Layer 'add21': Unconnected input. Each layer input must be connected to the output of another layer.
Detected unconnected inputs:
input 'in2'
Layer 'add22': Unconnected input. Each layer input must be connected to the output of another layer.
Detected unconnected inputs:
input 'in2'
Layer 'add31': Unconnected input. Each layer input must be connected to the output of another layer.
Detected unconnected inputs:
input 'in2'
Layer 'add32': Unconnected input. Each layer input must be connected to the output of another layer.
Detected unconnected inputs:
input 'in2'

Answers (1)

Gayathri
Gayathri on 24 Dec 2024 at 4:32
The "unconnected inputs" error is occuring as in layers there are some unconnected errors. Please modify the line of code from
convnet= trainNetwork(trainData,layers,options);
to
convnet= trainNetwork(trainData,lgraph,options);
All the connections are made in "lgraph". So now the error will be resolved.
For more information about "layerGraph", please run the following command in the command window.
doc layerGraph
Hope this helps!

Categories

Find more on Image Data Workflows in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!