Error using trainNetwork (line 184) Invalid network. Error in one (line 38) trainedNet = trainNetwork(imdsTrain,layers,opts)
조회 수: 3 (최근 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:
댓글 수: 0
답변 (1개)
Divya Gaddipati
2021년 5월 10일
You can refer to this example to know more about how to define a network for training:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!