Pausing reinforcement learning by forcing
4 次查看(过去 30 天)
显示 更早的评论
I'm running reinforcement learning, but I think there are times when I think it's not going well and want to stop it.
If you stop today's learning agent executed with the code below with Training stopped, simulink will freeze and stop working.
Repeatedly hitting the escape key doesn't work either.
so that you can stop it properly
Is there something wrong with the code?
numObs = 9;
obsInfo = rlNumericSpec([numObs 1]);
obsInfo.Name = "observations";
mdl = "kineticmodel_wIAVFBC_IncS2Ea_NH3FBC";
open_system(mdl)
numAct = 1;
actInfo = rlNumericSpec([numAct 1],LowerLimit=0,UpperLimit=1);
actInfo.Name = "NH3";
blk = mdl + "/RL agent/RL Agent";
env = rlSimulinkEnv(mdl,blk,obsInfo,actInfo);
Ts = 1
agent = createDDPGAgent(numObs,obsInfo,numAct,actInfo,Ts);
maxEpisodes = 2000;
Tf = 1240*3
maxSteps = floor(Tf/Ts);
trainOpts = rlTrainingOptions(...
MaxEpisodes=maxEpisodes,...
MaxStepsPerEpisode=maxSteps,...
ScoreAveragingWindowLength=250,...
Verbose=false,...
Plots="training-progress",...
StopTrainingCriteria="EpisodeCount",...
StopTrainingValue=maxEpisodes,...
SaveAgentCriteria="EpisodeCount",...
SaveAgentValue=maxEpisodes);
doTraining = true;
if doTraining
% Train the agent.
trainingStats = train(agent,env,trainOpts);
else
% Load a pretrained agent for the selected agent type.
if strcmp(AgentSelection,"DDPG")
load("rlWalkingBipedRobotDDPG.mat","agent")
else
load("rlWalkingBipedRobotTD3.mat","agent")
end
end
0 个评论
采纳的回答
Emmanouil Tzorakoleftherakis
2024-1-9
The proper way to stop it would be through the Episode Manager (top right of the window). Does this not work for you?
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!