Pausing reinforcement learning by forcing
조회 수: 2 (최근 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!