MATLAB Answers

How to classify with DAG network from checkpoint

54 views (last 30 days)
Yoshinori Abe
Yoshinori Abe on 12 Oct 2018
Commented: carlos arizmendi on 23 Nov 2019
I want to use classify() with DAG network from checkpoint network.
I trained inceptionv3 by transfer learning for a long epochs and it was successed. I set 'CheckpointPath' and have networks at each epoch. I want to evaluate these networks, so I loaded one and used classify(). But error message occuerd and it said "Use trainNetwork". How can I use classify() with network loaded from checkpoint?

  3 Comments

Naoya
Naoya on 15 Oct 2018
Could you please provide the whole error message and the exact command that you executed?
Yoshinori Abe
Yoshinori Abe on 15 Oct 2018
Thank you for your comment.
My training code is below:
net = inceptionv3();
lgraph = layerGraph(net);
lgraph = removeLayers(lgraph, {'predictions','predictions_softmax','ClassificationLayer_predictions'});
numClasses = 2;
newlayers = [ ...
fullyConnectedLayer(numClasses,'Name','fc','WeightLearnRateFactor',20,'BiasLearnRateFactor',20)
softmaxLayer('Name','softmax')
classificationLayer('Name','classoutput')];
lgraph = addLayers(lgraph,newlayers);
lgraph = connectLayers(lgraph,'avg_pool','fc');
layers = lgraph.Layers;
connections = lgraph.Connections;
layers(1:281) = freezeWeights(layers(1:281));%mixed9までフリーズさせたつもり
lgraph = createLgraphUsingConnections(layers,connections);
optionsTransfer = trainingOptions('sgdm', ...
'MaxEpochs', 15, ...
'MiniBatchSize', 16, ...
'InitialLearnRate', 0.0001, ...
'CheckpointPath','c:\');
netTransfer = trainNetwork(Itrain,categtrain,lgraph,optionsTransfer);%Itrain and categtrain are loaded elesewhere
My test code is below:
load('c:\net_checkpoint__147__2018_10_11__14_02_59.mat');
categtest_test = classify(net,Itest); % Itest is loaded elsewhere
Error messages are below:
Error using nnet.internal.cnn.layer.BatchNormalization/predict (line 135)
Unable to use networks with batch normalization layers before training is complete. Use trainNetwork to complete network training.
Error in nnet.internal.cnn.DAGNetwork/predict (line 383)
outputActivations = thisLayer.predict(XForThisLayer);
Error in DAGNetwork/predict (line 622)
YBatch = predictNetwork.predict(X);
Error in DAGNetwork/classify (line 693)
scores = this.predict( X, varargin{:} );
Thanks in advance for you help.
carlos arizmendi
carlos arizmendi on 23 Nov 2019
I have now the same problem classifing, how did you fix this bug? Thanks a lot.

Sign in to comment.

Accepted Answer

Naoya
Naoya on 15 Oct 2018
Thank you very much for providing the details.
The checkpoint network containing BatchNormalization layers is not supported on the current latest release (R2018b). I will forward this functionality as an enhancement request to our development team.
We applogize for causing inconvenience on the current checkpoint functionality.

  4 Comments

Show 1 older comment
David Kirschner
David Kirschner on 29 Nov 2018
I agree. I have lost time trying to use one of my Checkpoints similar to Naoya's efforts. Please add this functionality ASAP.
Gediminas Simkus
Gediminas Simkus on 1 Mar 2019
Guys, what you could do is that you select the desired checkpoint and set in your trainingOptions to train with very little 'InitialLearnRate' for a single epoch. That shouldn't change your model much and end up with deployed network model.
carlos arizmendi
carlos arizmendi on 23 Nov 2019
i have the same problem just rigth now and i am running over 2019b deep learning toolbox version, ¡how can i fix the problem?, i nedd this as quick as posible. Thank you
Error using nnet.internal.cnn.layer.BatchNormalization/predict (line 135)
Unable to use networks with batch normalization layers before training is complete. Use trainNetwork to complete
network training.
Error in nnet.internal.cnn.DAGNetwork/predict (line 383)
outputActivations = thisLayer.predict(XForThisLayer);
Error in DAGNetwork/predict (line 622)
YBatch = predictNetwork.predict(X);
Error in DAGNetwork/classify (line 693)
scores = this.predict( X, varargin{:} );

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Products


Release

R2018b

Translated by