How to save and use the pre-trained DQN agent in the reinforcement learning tool box
12 ビュー (過去 30 日間)
古いコメントを表示
I would like to use the DQN agent pre-trained in the following neural network to solve other problems. How can I save the pre-trained DQN agent. Also, how can I use this trained agent to solve other problems.
lgraph = layerGraph();
tempLayers = [
imageInputLayer([1 1 1],"Name","Block Actions","Normalization","none")
fullyConnectedLayer(50,"Name","fc_2")
reluLayer("Name","relu_2")];
lgraph = addLayers(lgraph,tempLayers);
tempLayers = [
imageInputLayer([20 1 1],"Name","Block Observations","Normalization","none")
scalingLayer("Name","scaling","Scale",12)
fullyConnectedLayer(50,"Name","fc_1")
reluLayer("Name","relu_1")];
lgraph = addLayers(lgraph,tempLayers);
tempLayers = [
additionLayer(2,"Name","addition")
fullyConnectedLayer(10,"Name","fc_3")
reluLayer("Name","relu_3")
fullyConnectedLayer(1,"Name","stateValue")];
lgraph = addLayers(lgraph,tempLayers);
0 件のコメント
回答 (1 件)
Emmanouil Tzorakoleftherakis
2021 年 1 月 16 日
Hello,
if doTraining
% Train the agent.
trainingStats = train(agent,env,trainOpts);
% Save the agent
save myagent.mat agent
else
% Load the pretrained agent for the example.
load('MATLABCartpoleDQNMulti.mat','agent')
end
3 件のコメント
Maha Mosalam
2022 年 3 月 22 日
So when I use the pretrained agent after that to get actions, I should defined the whole algorithm , I mean(the environment action space , actor and critic layers , expect the trainig line , just
use load(myagent.mat, agent)
Maha Mosalam
2022 年 3 月 23 日
Warning: Cannot load an object of class 'rlDLNetworkModel':
Its class cannot be found.
Warning: Cannot load an object of class 'rlADAMOptimizer':
Its class cannot be found.
Warning: While loading an object of class 'rl.representation.rlQValueRepresentation':
Undefined function 'getLoss' for input arguments of type 'double'.
Warning: Cannot load an object of class 'rlDLNetworkModel':
Its class cannot be found.
.....
I got these mesege when just
load(myagent.mat, agent)
then get action from that, not redefined the actor and critic, and environment
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!