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

6 visualizaciones (últimos 30 días)
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:

Respuestas (1)

Divya Gaddipati
Divya Gaddipati el 10 de Mayo de 2021
You can refer to this example to know more about how to define a network for training:

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by