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

26 ビュー (過去 30 日間)
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 = [
layers
fullyConnectedLayer(numClasses,'WeightLearnRateFactor',20,'BiasLearnRateFactor',20)
softmaxLayer
classificationLayer];
%
% 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:

回答 (1 件)

Divya Gaddipati
Divya Gaddipati 2021 年 5 月 10 日
You can refer to this example to know more about how to define a network for training:

カテゴリ

Help Center および File ExchangeDeep Learning Toolbox についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by