MATLAB: How to TRAIN further a previously trained agent

ddpgpre-trained agentReinforcement Learning Toolbox

Hi,
My agent was programmed to stop after reaching an average reward of X. How do I load and extend the training further?
I did enable saving of the experiences and it has created the agent file
Rajesh

Best Answer

Hi Sourav, I figured it out after reading the documentation moer carefully!
I need to also set the ResetExperienceBufferBeforeTraining flag if I need to use previously saved experiences
This is my working code snippet. I must say this is a great feature and I really missed knowing about it!
USE_PRE_TRAINED_MODEL = true; % Set to true, to use pre-trained
% Set agent option parameter:
agentOpts.ResetExperienceBufferBeforeTraining = not(USE_PRE_TRAINED_MODEL);
if USE_PRE_TRAINED_MODEL
% Load experiences from pre-trained agent
sprintf('- Continue training pre-trained model: %s', PRE_TRAINED_MODEL_FILE);
load(PRE_TRAINED_MODEL_FILE,'saved_agent');
agent = saved_agent;
else
% Create a fresh new agent
agent = rlDDPGAgent(actor, critic, agentOpts);
end
% Train the agent
trainingStats = train(agent, env, trainOpts);