Logging needed Information while training a Reinforcement learning agent.

2 次查看(过去 30 天)
Hello everyone
Currently I am using RL to develop an algorithm to optimize 3D movementof a UAV using certaint models and calculations. some of the data are used for reward and some are not but they are important for my research. I found that i could save those in loggedsignals, but as it gets bigger, it slows the training after a while, although Its useful for one episode or one simulation. Is there a better way to log or save these unused yet important data?
Thank you

采纳的回答

Ari Biswas
Ari Biswas 2024-3-1
Unfortunately there is no straightforward way to do this currently but we may have a solution in the upcoming releases (stay tuned).
For now you can add the following code in your environment reset function. It will save the logged signals to disk and remove it from memory to improve performance.
currentDir = pwd;
env.ResetFcn = @(in) myResetFcn(in, currentDir);
function in = myResetFcn(in, currentDir)
% your reset code...
% create a unique name for each episode.
% For parallel training use uuid to avoid incorrect episode indices.
% s = matlab.lang.internal.uuid;
s = string(datetime("now"),"yyyyMMddhhmmss");
filename = fullfile(currentDir, "loggedData_" + s + ".mat");
% process the logged data post episode simulation
in = in.setPostSimFcn(@(x) myPostSim(x, filename));
end
function new_out = myPostSim(out, filename)
% save the logged data to disk
% "logsout" is the name specified in your model settings > Data Import/Export > Signal logging
loggedData = out.logsout;
save(filename, "loggedData");
% remove logged data from out
new_out = out;
new_out.logsout = [];
new_out.tout = []
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Training and Simulation 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by