DLR-RM / stable-baselines3

PyTorch version of Stable Baselines, reliable implementations of reinforcement learning algorithms.
https://stable-baselines3.readthedocs.io
MIT License
8.35k stars 1.6k forks source link

[Question] SAC, a torch model becomes a bool somehow #1930

Closed JaimeParker closed 1 month ago

JaimeParker commented 1 month ago

❓ Question

I'm using a customized env, doing a model.learn, and the error log is:

Traceback (most recent call last):
  File "train.py", line 94, in <module>
    model.learn(total_timesteps=int(log_total_steps), progress_bar=True)
  File "/home/sjtu2327/stable_baselines3/sac/sac.py", 
line 307, in learn
    return super().learn(
  File 
"/home/table_baselines3/common/off_policy_algo
rithm.py", line 347, in learn
    self.train(batch_size=self.batch_size, gradient_steps=gradient_steps)
  File "/home/sjtu2327/stable_baselines3/sac/sac.py", 
line 201, in train
    self.policy.set_training_mode(True)
  File 
"/home/sjtu2327/stable_baselines3/sac/policies.py", line
364, in set_training_mode
    self.critic.set_training_mode(mode)
  File 
"/home/sjtu2327/stable_baselines3/common/policies.py", 
line 211, in set_training_mode
    self.train(mode)
  File 
"/home/sjtu2327/3rdParty/anaconda3/envs/sb3/lib/python3.8/site-packages/torch/nn/modules/module.
py", line 2394, in train
    module.train(mode)
  File 
"/home/sjtu2327/3rdParty/anaconda3/envs/sb3/lib/python3.8/site-packages/torch/nn/modules/module.
py", line 2394, in train
    module.train(mode)
  File 
"/home/sjtu2327/3rdParty/anaconda3/envs/sb3/lib/python3.8/site-packages/torch/nn/modules/module.
py", line 2394, in train
    module.train(mode)
AttributeError: 'bool' object has no attribute 'train'

pretty weird, how could a torch nn module became a bool?

I'm using:

Checklist

qgallouedec commented 1 month ago

Hi, thanks for reporting, but next time, please read the form more carefully:

Important Note: If your question is anything like "Why is my code generating this error?", you must submit a bug report instead.

It's hard to understand this error as it stands, too many context elements are missing. You'd have to provide all the elements requested in the custom env issue template. Feel free to close this issue and open a new one if it's easier for you.