thu-ml/tianshou

AttributeError: 'PPOPolicy' object has no attribute 'set_eps'

prologua opened this issue · 2 comments

result = ts.trainer.offpolicy_trainer(
policy, train_collector, test_collector, epoch, step_per_epoch, step_per_collect,
test_num, batch_size, update_per_step=1 / step_per_collect,
train_fn=lambda epoch, env_step: policy.set_eps(eps_train),
test_fn=lambda epoch, env_step: policy.set_eps(eps_test),
stop_fn=lambda mean_rewards: mean_rewards >= env.spec.reward_threshold,
logger=logger )
policy = ts.policy.PPOPolicy(net, optim, gamma, n_step)

When I run the above code, I get an AttributeError: 'PPOPolicy' object has no attribute 'set_eps'. Did the tianshou update remove set_eps()? I don't know how to solve it, can anybody give me some advice?

my versions: python==3.12 tianshou==0.5.1

Hi @prologua. 0.5.1 is still an old version, far behind the current 1.0.0 and master.

We haven't removed set_eps, but I doubt it was ever there for PPO. Some discrete action policies like DQNPolicy or C51 have it, it's not part of the BasePolicy inteface.

Let me know if this resolves your question

Resolving as answered, feel free to comment if you think otherwise