What is the best way to :
- make checkpoint by ray.tune.run
- load checkpoint by PPOTrainer
- Show checkpoint by tensorflow model.summary ?
I try to make checkpoint by :
from ray import tune
tune.run("PPO",
config={
"env":"CartPole-v0",
"framework": "tf2",
"evaluation_interval":2,
"evaluation_duration":20,
},
local_dir="cartpole",
checkpoint_freq=2)
next, load model by:
from ray.rllib.agents.ppo.ppo import PPOTrainer
import gym
config = {
"env": "CartPole-v0",
"framework": "tf2",
"evaluation_interval": 2,
"evaluation_duration": 20,
}
agent = PPOTrainer(config=config)
agent.restore("./cartpole/PPO/PPO_CartPole-v0_23a86_00000_0_2022-06-30_16-24-39/checkpoint_000002/checkpoint-2")
agent.load_checkpoint()
env = gym.make("CartPole-v0")
obs = env.reset()
while True:
action = agent.compute_action(obs)
obs, reward, done, _ = env.step(action)
if done:
break
env.close()
but there is error:
File "/home/ppirog/projects/Mastering-Reinforcement-Learning-with-Python/3D_observations/run_saved_checkpoint.py", line 13, in <module>
agent.load_checkpoint()
TypeError: load_checkpoint() missing 1 required positional argument: 'checkpoint_path'
Exception ignored in: <function RolloutWorker.__del__ at 0x7fd2f9785e50>
Traceback (most recent call last):
File "/home/ppirog/projects/Mastering-Reinforcement-Learning-with-Python/venv/lib/python3.8/site-packages/ray/util/tracing/tracing_helper.py", line 461, in _resume_span
TypeError: 'NoneType' object is not callable
Exception ignored in: <function RolloutWorker.__del__ at 0x7fd2f9772a60>
Traceback (most recent call last):
File "/home/ppirog/projects/Mastering-Reinforcement-Learning-with-Python/venv/lib/python3.8/site-packages/ray/util/tracing/tracing_helper.py", line 461, in _resume_span
TypeError: 'NoneType' object is not callable
Process finished with exit code 1
At last i try to show model:
import tensorflow as tf
model_path="./cartpole/PPO/PPO_CartPole-v0_23a86_00000_0_2022-06-30_16-24-39/checkpoint_000002/"
new_model = tf.keras.models.load_model(model_path)
new_model.summary()
But there is error:
OSError: SavedModel file does not exist at: /home/ppirog/projects/Mastering-Reinforcement-Learning-with-Python/3D_observations/cartpole/PPO/PPO_CartPole-v0_2890c_00000_0_2022-06-30_16-03-19/checkpoint_000002/{saved_model.pbtxt|saved_model.pb}