Pausing reinforcement learning by forcing

조회 수: 2 (최근 30일)
SHromaneko
SHromaneko 2024년 1월 2일
편집: SHromaneko 2024년 1월 10일
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

채택된 답변

Emmanouil Tzorakoleftherakis
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?
  댓글 수: 1
SHromaneko
SHromaneko 2024년 1월 10일
편집: SHromaneko 2024년 1월 10일
It's just a bug, I re-installed and fixed it.
Thanks a lot.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Reinforcement Learning에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by