Closed WynnCJF closed 2 years ago
Hi @WynnCJF. Looking at baselines code it seems indeed there was a change with the integration of tensorflow2: save
and load
methods were removed from PolicyWithValue
class (see https://github.com/openai/baselines/blob/tf2/baselines/common/policies.py).
A possible fix (not tested):
policy = trpo_mpi.learn(env=env,
network=mlp(num_hidden=32, num_layers=2),
total_timesteps=num_timesteps,
#timesteps_per_batch=1*1024, max_kl=0.01, cg_iters=10, cg_damping=0.1,
timesteps_per_batch=16*1024, max_kl=0.01, cg_iters=10, cg_damping=0.1,
gamma=0.99, lam=0.98, vf_iters=5, vf_stepsize=1e-3
)
import tensorflow as tf
save_path="/root/rl-testbed-for-energyplus/model.path"
ckpt = tf.train.Checkpoint(model=policy)
manager = tf.train.CheckpointManager(ckpt, save_path, max_to_keep=None)
manager.save()
Hope it helps!
Thanks Antoine! This solves our problem.
As #88 indicates, I tried to save the model in this way but failed:
The error message is
Is the saving method changed? Thanks in advance!