how to freeze and reset the weights to initial values of neural network.?

조회 수: 20 (최근 30일)
Sourabh
Sourabh 2024년 1월 29일
I have a trained RL agent and now i want to retrain only a selected few layers of same agent while keeping some of layers of actor and critic to remain freezed. how can i do it ? I am attaching a agent for reference .
So i need two things one is how to freeze a certain layers of actor and critic network while training an RL agent again.
and how can i reset the weights of a specific layer of trained RL agent`s actor and critic network.
any help would be really appreciated thanks.

답변 (1개)

Emmanouil Tzorakoleftherakis
Emmanouil Tzorakoleftherakis 2024년 2월 12일
You can accomplish what you asked with something along the lines of:
init_model = getModel(getCritic(agent));
new_model_layers = init_model.Layers;
new_model_layers(2).WeightLearnRateFactor = 0; %select appropriate index
new_model_layers(2).Weights = single(zeros(20,4));
new_model = dlnetwork(new_model_layers);
%reset critic
critic = getCritic(agent);
critic = setModel(critic,new_model);
agent = setCritic(agent,critic);

카테고리

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