loading and training an existing network.

2 vues (au cours des 30 derniers jours)
Mark Hubelbank
Mark Hubelbank le 7 Oct 2024
Modifié(e) : Matt J le 8 Oct 2024
I am trying define a network, then train it in multiple sessions. The problem is that I can't get the load or read of the network to work in the second session. The code is:
layers = [ ...
sequenceInputLayer(270)
bilstmLayer(numHiddenUnits,OutputMode="last")
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer]
options = trainingOptions("adam", ...
InitialLearnRate=0.002,...
MaxEpochs=15, ...
Shuffle="never", ...
GradientThreshold=1, ...
Verbose=false, ...
ExecutionEnvironment="gpu", ...
Plots="training-progress");
clabels=categorical(labels);
numLables=numel(clabels)
load("savednet.mat","layers");
net = trainNetwork(data,clabels,layers,options);
save("savednet","net");
I have tried many variations of the load command and it always gives an error on the second argument:
Warning: Variable 'layers' not found.
Exactly what should that look like and then how should it be used as input to the trainNetwork routine?
  7 commentaires
Mark Hubelbank
Mark Hubelbank le 7 Oct 2024
Déplacé(e) : Walter Roberson le 7 Oct 2024
Perhaps I don't understand how one can train in stages then. The idea is that the training will be continued in the second and subsequent sessions. Sort of a continuing transfer learning. The idea is that over time the network keeps improving. perhaps I should be using trainnet instead of trainnetwork. Then it would appear the call is:
load(filename,"net1","layers");
net=trainnet(data,clabels,net1,"crossentropy",options);
Is this the correct direction?
Walter Roberson
Walter Roberson le 7 Oct 2024
Probably
net1 = trainnet(data,clabels,net1,"crossentropy",options);

Connectez-vous pour commenter.

Réponse acceptée

Matt J
Matt J le 7 Oct 2024
previous = load("savednet","net","layers");
net = trainNetwork(data,clabels,previous.net,options);
  1 commentaire
Matt J
Matt J le 7 Oct 2024
Modifié(e) : Matt J le 8 Oct 2024
perhaps I should be using trainnet instead of trainnetwork.
It would be better, since trainnet is newer and has more flexibility. However, it won't make a difference as far as how to resume the training of a pre-existing network..

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Image Data Workflows dans Help Center et File Exchange

Produits


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by