question about calculate loss value of dqn agent reinforcement learning
2 次查看(过去 30 天)
显示 更早的评论
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?
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 个评论
Emmanouil Tzorakoleftherakis
2023-6-27
编辑:Emmanouil Tzorakoleftherakis
2023-6-27
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
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!