How to retrain existing and trained Neural Network without destroying trained content?

72 vues (au cours des 30 derniers jours)
Matlab train() function used for training the neural network initializes all weights and other internal parameters of the network at the beginning. I would like to take a trained network and train it further using new set of data without reinitializing and starting from scratch (destroying the trained net basically). How do I do it ? Is there a way to use existing train() function or is there some re-train() function or do I need to build my own custom solution ? The last option seems unlikely, given the amount of the existing Matlab code. Please advise, Thanks, Mirek Wilmer mirek.wilmer@gmail.com
  1 commentaire
manisha milani
manisha milani le 29 Oct 2019
Modifié(e) : manisha milani le 29 Oct 2019
y=net(x) % y is the trained output
mynet = net;
save mynet;
load mynet;
test = mynet(new_data);

Connectez-vous pour commenter.

Réponses (4)

Greg Heath
Greg Heath le 7 Août 2018
Modifié(e) : Greg Heath le 7 Août 2018
TRAIN initializes weights ONLY IF ALL weights are zero.
OTHERWISE
TRAIN will update weights with the new data.
Therefore old weights will be modified to fit the new data.
If the new data is unlike the old data, performance on the old data will be degraded.
In order to prevent "FORGETTING", a characteristic subset of the old data SHOULD BE MIXED with the new data for the retraining.
Hope this helps.
Thank you for formally accepting my answer
Greg

Greg Heath
Greg Heath le 3 Août 2018
In order to preserve the dominant characteristics of the 1st dataset you must include that information while adapting to the new data. Therefore I always represent the 1st data set by a representative subset and add that to the new set.
I have been most successful when using Elliptic or Gaussian basis functions (with limited effective range) in the net.
Hope this helps.
Thank you for formally accepting my answer
Greg
  1 commentaire
TROY TULLY
TROY TULLY le 9 Avr 2021
Hi Greg,
Do you know of a way to have a computer search through the training data to find a represntative subset?

Connectez-vous pour commenter.


KSSV
KSSV le 23 Avr 2018
The function train gives out a structure variable net with all the information of training the inputs have under gone.
[net,tr] = train(net,.......)
If you don't clear your workspace, you can use the variable net for what you want. It will retain all the previous data.
[net,tr] = train(net,newdata.....)
  4 commentaires
Gideon Prior
Gideon Prior le 7 Août 2018
That isnt the case unfortunately. Calls to 'train' reinitialize the weights, which is odd since there is a method 'init' already included in the toolbox. I dont know why the mathworks folks decided to not include an option to prevent initialization when 'train' is called.
Kinga Wilmer
Kinga Wilmer le 7 Août 2018
As a mater of fact, if the workspace is not cleared and the definition of net is not changed, then train() function does not destroy the existing weights. I did trace the whole process with a debugger step by step and confirmed it. Therefore you can re-use your trained net for further training. Mind you, the additional data may re-train your net, so if you want to retain the existing trained capacity, you need to keep statistically important sample representation of your previous training data in the new training dataset. Therefore only small incremental retraining steps make sense. Another way is to train number of separate networks and combine them into hierarchical model.

Connectez-vous pour commenter.


kira
kira le 26 Sep 2018
If you want to train incrementally on your data set, you can also do it all at once by dealing with them as concurrent data https://www.mathworks.com/help/deeplearning/ug/multiple-sequences-with-dynamic-neural-networks.html

Catégories

En savoir plus sur Parallel and Cloud dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by