Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] with gSDE, calling policy.save() causes error #399

Closed
3 tasks done
liusida opened this issue Apr 19, 2021 · 1 comment · Fixed by #401
Closed
3 tasks done

[Bug] with gSDE, calling policy.save() causes error #399

liusida opened this issue Apr 19, 2021 · 1 comment · Fixed by #401
Assignees
Labels
bug Something isn't working

Comments

@liusida
Copy link

liusida commented Apr 19, 2021

🐛 Bug

Usually we use model.save(path) to save a zip file.
But policy also has a save method. If one call that method with gSDE enabled, it will produce an error.

To Reproduce

import pybullet_envs
from stable_baselines3 import PPO

model = PPO('MlpPolicy', 'HopperBulletEnv-v0', use_sde=True)
model.learn(100)
model.policy.save("/tmp/sde_policy")
Traceback (most recent call last):
  File "try_sde_with_policy_save.py", line 6, in <module>
    model.policy.save("/tmp/sde_policy")
  File "/home/liusida/code/code_trysb3/stable-baselines3/stable_baselines3/common/policies.py", line 152, in save
    th.save({"state_dict": self.state_dict(), "data": self._get_constructor_parameters()}, path)
  File "/home/liusida/code/code_trysb3/stable-baselines3/stable_baselines3/common/policies.py", line 438, in _get_constructor_parameters
    sde_net_arch=default_none_kwargs["sde_net_arch"],
KeyError: 'sde_net_arch'

Expected behavior

The policy (the PyTorch module) should be saved as a file.

### System Info

Describe the characteristic of your environment:

  • tested with pip install and also commit: 5d47296
  • GPU models and configuration: No GPU
  • Python version: 3.8
  • PyTorch version: 1.8.1
  • Gym version: 0.18.0

Checklist

  • I have checked that there is no similar issue in the repo (required)
  • I have read the documentation (required)
  • I have provided a minimal working example to reproduce the bug (required)
@liusida liusida added the bug Something isn't working label Apr 19, 2021
@araffin araffin self-assigned this Apr 19, 2021
@araffin
Copy link
Member

araffin commented Apr 19, 2021

Hello,
thanks for reporting the bug, will be fixed in #401 ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants