MATLAB Answers

Error using trainNetwork (line 184) Invalid network. Error in one (line 38) trainedNet = trainNetwo​rk(imdsTra​in,layers,​opts)

20 views (last 30 days)
Rallapalli Sethumadhavi
Rallapalli Sethumadhavi on 29 Apr 2021
Answered: Divya Gaddipati on 10 May 2021
I am trying to use the predefiend function of googlenet for image classification. But I am getting this error. please can anyone help me out of this.
numClasses = numel(categories(imdsTrain.Labels));
layers = [
% Create augmentedImageDatastore from training and test sets to resize
% images in imds to the size required by the network.
imageSize = net.Layers(1).InputSize;
augmentedTrainingSet = augmentedImageDatastore(imageSize, imdsTrain);
augmentedTestSet = augmentedImageDatastore(imageSize, imdsValidation);
opts = trainingOptions('sgdm','Plots','training-progress','ValidationData',augmentedTestSet, 'InitialLearnRate', 0.001, 'MaxEpochs', 10, 'MiniBatchSize', 64);
%trainedNet = trainNetwork(imdsTrain,layers,opts);
net = trainNetwork(augmentedTrainingSet, layers, opts);
predictedLabels = classify(net, augmentedTestSet);
testLabels = imdsValidation.Labels;
Error using trainNetwork (line 184)
Invalid network.
Error in one (line 38)
trainedNet = trainNetwork(imdsTrain,layers,opts);
Caused by:
Network: Too many output layers. The network must have one output layer.
Detected output layers:
layer 'output'
layer 147
Layer 'inception_3a-3x3_reduce': Input size mismatch. Size of input to this
layer is different from the expected input size.
Inputs to this layer:
from layer 'inception_3a-relu_1x1' (size 28(S) × 28(S) × 64(C) × 1(B))
Layer 'inception_3a-output': Unconnected input. Each layer input must be
connected to the output of another layer.
Detected unconnected inputs:

Community Treasure Hunt

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

Start Hunting!