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

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

Open
2 of 4 tasks
yq60523 opened this issue Jan 19, 2024 · 1 comment
Open
2 of 4 tasks
Labels
question Further information is requested

Comments

@yq60523
Copy link

yq60523 commented Jan 19, 2024

❓ 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_policy_agent.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

  • I have checked that there is no similar issue in the repo
  • I have read the documentation
  • If code there is, it is minimal and working
  • If code there is, it is formatted using the markdown code blocks for both code and stack traces.
@yq60523 yq60523 added the question Further information is requested label Jan 19, 2024
@yuanmingqi
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants