Denys88 / rl_games

RL implementations
MIT License
800 stars 135 forks source link

AttributeError: 'dict' object has no attribute 'clone' in SAC algorithm #263

Closed scxzhchacker closed 7 months ago

scxzhchacker commented 7 months ago

When I used the SAC algorithm with rl-games==1.6.1, the following error occurred

  File "/home/zhc/.local/share/ov/pkg/isaac_sim-2022.2.1/kit/python/lib/python3.7/site-packages/rl_games/algos_torch/sac_agent.py", line 497, in play_steps
    self.obs = next_obs.clone()
AttributeError: 'dict' object has no attribute 'clone'

Check the source code of the error section

            next_obs, rewards, dones, infos = self.env_step(action)

           # some  code

            if isinstance(next_obs, dict):    
                next_obs_processed = next_obs['obs']

            self.obs = next_obs.clone()

The next_obs returned by self.env_step(action) must be a dict after being packaged by the cast_obs function, but the error is reported when next_obs.clone() is called later.

Denys88 commented 7 months ago

hi, @scxzhchacker did you solve your problem?

ViktorM commented 7 months ago

Hi @scxzhchacker I will push the fix later today.