How to keep constant weights in a Neural Network?

조회 수: 5 (최근 30일)
Enrique Luna Villagomez
Enrique Luna Villagomez 2021년 6월 4일
댓글: Enrique Luna Villagomez 2021년 6월 5일
Hi, I am trying to train only certain parameters of neural network in MATLAB 2021a, but I have not found anything related in the help menu.
I have found that it is possible to keep constant all the parameters of a certain layer by changing the layer attribute "trainable" to false, but in this case I would like to train some parameters of the layer. (Ex. There are 6 parameters in the layer and I want to fix two and train the remanining ones).
Thanks for your attention.

답변 (1개)

SALAH ALRABEEI
SALAH ALRABEEI 2021년 6월 5일
Assume u have 5 inputs 10 ne. (for only on hidden layer). First, generate yourself a random matrix of size 5x10, then save it. Then construct the net, but before the training, replace weight with the one you manually created as follows
if true
net.Layers(k).Weights = W;
end
where net is the name of ur ne, W is new weights, and k is the layer.
  댓글 수: 1
Enrique Luna Villagomez
Enrique Luna Villagomez 2021년 6월 5일
Thanks for your answer, but if the train function is after that conditional, the weights would change at the end right ? I mean basically what I will be doing with that conditional is to initialize the weights.

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

카테고리

Help CenterFile Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by