How to check the change of weight in reinforcement learning training?

1 Ansicht (letzte 30 Tage)
Xianjin Zhu
Xianjin Zhu am 10 Jul. 2022
Beantwortet: Nithin am 9 Apr. 2025
I have read the example "tune PI controller using reinforcement learning". And I wonder how to check the change of weights of the actor network every step? Could anyone help me? Thanks very much!

Antworten (1)

Nithin
Nithin am 9 Apr. 2025
To monitor the change in weights of the actor network at every step during training in the example "Tune PI Controller Using Reinforcement Learning", you can use a custom callback function to record the model weights at each step.
You can create a custom callback function to extract and log the weights of the actor network which will be called at each training step.
global weightsHistory;
weightsHistory = [];
% Custom callback function to log actor weights
function stop = logActorWeights(agent, ~, ~)
global weightsHistory;
actor = getActor(agent);
parameters = getLearnableParameters(actor);
% Append the current weights to the history
weightsHistory = [weightsHistory; parameters{1}(:)'];
stop = false;
end
"logActorWeights" function is defined to extract the learnable parameters (weights) of the actor network and append them to "weightsHistory".
Then, add the callback function to the training options
trainOpts = rlTrainingOptions(...
MaxEpisodes=maxepisodes, ...
MaxStepsPerEpisode=maxsteps, ...
ScoreAveragingWindowLength=100, ...
Verbose=false, ...
Plots="training-progress", ...
StopTrainingCriteria="AverageReward", ...
StopTrainingValue=-355, ...
Callbacks=@logActorWeights); % Add the callback function
Hope this answers your query.

Kategorien

Mehr zu Deep Learning Toolbox finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by