How can I freeze specific weights of Neural network model?
43 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Abdelwahab Afifi
il 14 Giu 2020
Modificato: Ahmad Gad
il 25 Ago 2021
I need to set some specific weights before training, and keep these weights fixed during training
0 Commenti
Risposta accettata
Utkarsh
il 18 Giu 2020
Hi Abdelwahab,
If you wish to assign those weights in the beginning and keep them as constant, you can set the ‘WeightLearnRateFactor’ property as 0 (which defines the learning rate for that layer) for those layers.
For example,
convolution2dLayer(3,1,'Padding',[1 1 1 1],'WeightLearnRateFactor',0);
Or if you want to fix certain weights to some layers in a trained network , then directly assign those layers the values after training the network.
net = alexnet; % or your pre-trained network
layer = net.Layers(1) % here 1 can be replaced with the layer number you wish to change
layer.Weights = randn(11,11,3,96); %the weight matrix which you wish to assign
1 Commento
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Deep Learning Toolbox in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!