I have installed add-on 'Deep Learning Toolbox' and 'Deep Learning Toolbox model for mobilenetv2' and used the below code net = mobilenetv2; % Load pretrained MobileNet model numClasses = numel(classNames); layers = [ net.Layers(1:end-3) fullyConnectedLayer(numClasses,'Name','fc') softmaxLayer('Name','softmax') classificationLayer('Name','classoutput')]; options = trainingOptions('adam', ... 'MaxEpochs',10, ... 'MiniBatchSize',32, ... 'ValidationData',imdsValidation, ... 'ValidationFrequency',5, ... 'InitialLearnRate',1e-4, ... 'LearnRateSchedule','piecewise', ... 'LearnRateDropFactor',0.1, ... 'LearnRateDropPeriod',5, ... 'L2Regularization',0.01, ... 'Plots','training-progress'); % Train the network net = trainNetwork(imdsTrain,layers,options); and I got the error message below Error using trainNetwork invalid network. caused by: Layer 'block_11_add' Unconnected input. Each layer input must be connected to the output of another layer. Layer 'block_12_add' Unconnected input. Each layer input must be connected to the output of another layer. Layer 'block_14_add' Unconnected input. Each layer input must be connected to the output of another layer. Layer 'block_15_add' Unconnected input. Each layer input must be connected to the output of another layer. Layer 'block_2_add' Unconnected input. Each layer input must be connected to the output of another layer. Layer 'block_4_add' Unconnected input. Each layer input must be connected to the output of another layer. Layer 'block_5_add' Unconnected input. Each layer input must be connected to the output of another layer. Layer 'block_7_add' Unconnected input. Each layer input must be connected to the output of another layer. Layer 'block_8_add' Unconnected input. Each layer input must be connected to the output of another layer. Layer 'block_9_add' Unconnected input. Each layer input must be connected to the output of another layer. I don`t know why this error happens... maybe using pretrained model intrigue error depends on the data?
John Williams answered .
2025-11-20