Save intermediate model in matlab while training a deep learning model and resume training from that stage later
이전 댓글 표시
Hi,
I am training a 3 pipeline deep learning model in matlab which takes a lot of time to train. I need to store intermediate variable values while training, stop the training process and then resume training at a later point from the stage at which the training was stopped previously. Does Matlab have any options to do this? Any help in this regard would be highly appreciated.
Thanks in Advance
채택된 답변
추가 답변 (1개)
yanqi liu
2021년 10월 15일
sir,may be use CheckpointPath,such as
options = trainingOptions('sgdm', ...
'MaxEpochs', 5, ...
'MiniBatchSize', 1, ...
'InitialLearnRate', 1e-3, ...
'CheckpointPath', tempdir);
댓글 수: 1
SIMON
2025년 7월 26일
Hello everyone, here is a nice example of how you can save your model everytime you train it again and again and again:
% 🧱 Define LSTM model
layers = [
sequenceInputLayer(size(featuresNorm, 2))
lstmLayer(50, 'OutputMode', 'last') % Capture temporal info
dropoutLayer(0.2) % Prevent overfitting
fullyConnectedLayer(size(targetNorm, 2))
regressionLayer
];
% ⚙️ Set training options
options = trainingOptions('adam', ...
'MaxEpochs', 100, ...
'MiniBatchSize', 32, ...
'InitialLearnRate', 0.005, ...
'GradientThreshold', 1, ...
'Shuffle', 'every-epoch', ...
'ValidationFrequency', 30, ...
'ValidationPatience', 5, ...
'Plots', 'training-progress', ...
'Verbose', false);
% Load the model
if isfile('trainedLSTMModel.mat')
load('trainedLSTMModel.mat', 'net');
layers = net.Layers
end
% 🚀 Train the network
net = trainNetwork(featureSequence, targetNorm, layers, options);
save('trainedLSTMModel.mat', 'net');
Now can you lovely people please visit my website called spacetripping and have a lovely time.
카테고리
도움말 센터 및 File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!