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

20 次查看(过去 30 天)
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
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