RLE-Foundation / rllte

Long-Term Evolution Project of Reinforcement Learning
https://docs.rllte.dev/
MIT License
449 stars 83 forks source link

[Question] AttributeError: 'Categorical' object has no attribute 'dist' #43

Open yq60523 opened 5 months ago

yq60523 commented 5 months ago

❓ Question

When I try the code in intrinsic_reward_shaping.ipynb, I get an error.

The detailed error are as the following:

Traceback (most recent call last): File "/home/x1/anaconda3/envs/x2/lib/python3.8/code.py", line 90, in runcode exec(code, self.locals) File "", line 1, in File "/opt/PyCharm/pycharm-professional-2022.2.4/pycharm-2022.2.4/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 198, in runfile pydev_imports.execfile(filename, global_vars, local_vars) # execute the script File "/opt/PyCharm/pycharm-professional-2022.2.4/pycharm-2022.2.4/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/home/x1/PycharmProjects/ddpg-pytorch/test_rllte/test1.py", line 24, in agent.train(num_train_steps=5000) File "/home/x1/PycharmProjects/ddpg-pytorch/rllte/rllte/common/prototype/on_policy_agent.py", line 112, in train eval_metrics = self.eval(num_eval_episodes) File "/home/x1/PycharmProjects/ddpg-pytorch/rllte/rllte/common/prototype/on_policyagent.py", line 231, in eval actions, = self.policy(obs, training=False) File "/home/x1/anaconda3/envs/x2/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, kwargs) File "/home/x1/anaconda3/envs/x2/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(*args, *kwargs) File "/home/x1/anaconda3/envs/x2/lib/python3.8/site-packages/torch/_dynamo/eval_frame.py", line 328, in _fn return fn(args, kwargs) File "/home/x1/anaconda3/envs/x2/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "/home/x1/anaconda3/envs/x2/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(args, **kwargs) File "/home/x1/PycharmProjects/ddpg-pytorch/rllte/rllte/xploit/policy/on_policy_shared_actor_critic.py", line 147, in forward def forward(self, obs: th.Tensor, training: bool = True) -> Tuple[th.Tensor, Dict[str, th.Tensor]]: File "/home/x1/PycharmProjects/ddpg-pytorch/rllte/rllte/xplore/distribution/categorical.py", line 99, in mean return self.dist.probs.argmax(axis=-1) AttributeError: 'Categorical' object has no attribute 'dist'

Can you help me to solve this problem?

Checklist

yuanmingqi commented 4 months ago

Sorry for the very late reply. We've experienced a big update recently, I think now you can successfully run the example.

If you have any other questions, please don't hesitate to ask here.