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.
0 个评论
回答(1 个)
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);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!