I want to train a network and save the weights. Then use a new data set and resume training with the weights from the previous data set.

조회 수: 4 (최근 30일)
It seems train always randomizes the weights when called. I can't seem to maintain the weights from the first training set.

채택된 답변

Sonam Gupta
Sonam Gupta 2018년 3월 28일
You can continue the training from weights obtained by previous data set by extracting the layers from the network's "Layers" property, and then passing it to "trainNetwork", as follows:
if true
% Train a network
net = trainNetwork(XTrain, YTrain, layers, options);
% Extract layers from the trained network
newLayers = net.Layers;
% Retrain the network, but start from where we left off
newNet = trainNetwork(XTrain, YTrain, newLayers, options);
'trainNetwork' will always use the weights that are stored in the layers which you pass in for training.
  댓글 수: 3
Moh. Saadat
Moh. Saadat 2022년 8월 29일
There is a small caveat to this: check that whether your output 'net' is a LayerGraph or a DAGNetwork. If it is not a LayerGraph, use layerGraph(net) instead of net.Layers.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by