question about calculate loss value of dqn agent reinforcement learning
3 views (last 30 days)
Show older comments
hello everyone,
I want to plot curve of loss value during training. It is not available in dqn training option directly as i know. My question is :
can i calculate loss simply with this function?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1419183/image.png)
Q0 is predicted value by critic. (orange line in default process-training plot)
EpisodeReward is gained reward by agent in t episode
t is number of episode
%% example code for loss plotting here
% unpack training statistic
index = trainingStats.EpisodeIndex;
reward = trainingStats.EpisodeReward;
pred_reward = trainingStats.EpisodeQ0;
Loss_Plot = [];
for t = 1:size(index, 1)
loss = (sum(pred_reward(1:t, 1)) - sum(reward(1:t, 1)))/t
Loss = [t, loss];
Loss_Plot = [Loss_Plot; Loss]
end
% plot curve
plot(Loss_Plot(:, 1), Loss_Plot(:, 2), '-')
can i plot loss value of episode with this example code properly?
thanks in advance.
Kun
1 Comment
Emmanouil Tzorakoleftherakis
on 27 Jun 2023
Edited: Emmanouil Tzorakoleftherakis
on 27 Jun 2023
Which version are you using? You can log loss data following the guidelines here: https://www.mathworks.com/help/reinforcement-learning/ug/log-training-data-to-disk.html
Answers (0)
See Also
Categories
Find more on Training and Simulation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!