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

运行DI-Zoo里面写好的config报错 #646

Closed
4 of 11 tasks
Tracked by #548
xujinming01 opened this issue Apr 17, 2023 · 2 comments
Closed
4 of 11 tasks
Tracked by #548

运行DI-Zoo里面写好的config报错 #646

xujinming01 opened this issue Apr 17, 2023 · 2 comments
Labels
bug Something isn't working config Update config

Comments

@xujinming01
Copy link

  • I have marked all applicable categories:
    • exception-raising bug
    • RL algorithm bug
    • system worker bug
    • system utils bug
    • code design/refactor
    • documentation request
    • new feature request
  • I have visited the readme and doc
  • I have searched through the issue tracker and pr tracker
  • I have mentioned version numbers, operating system and environment, where applicable:
    import ding, torch, sys
    print(ding.__version__, torch.__version__, sys.version, sys.platform)
v0.4.7 1.12.1+cpu 3.9.12 (main, Apr  4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)] win32

直接在Pycharm里面运行DI-engine\dizoo\gym_hybrid\config\gym_hybrid_pdqn_config.py报错:

Traceback (most recent call last):
  File "C:\Users\arche\code\repository\DI-engine\dizoo\gym_hybrid\config\gym_hybrid_pdqn_config.py", line 76, in <module>
    serial_pipeline([main_config, create_config], seed=0, max_env_step=int(1e7))
  File "C:\Users\arche\code\repository\DI-engine\ding\entry\serial_entry.py", line 97, in serial_pipeline
    stop, eval_info = evaluator.eval(learner.save_checkpoint, learner.train_iter, collector.envstep)
  File "C:\Users\arche\code\repository\DI-engine\ding\worker\collector\interaction_serial_evaluator.py", line 314, in eval
    return_info = to_item(return_info)
  File "C:\Users\arche\code\repository\DI-engine\ding\torch_utils\data_helper.py", line 301, in to_item
    return [to_item(d) for d in data]
  File "C:\Users\arche\code\repository\DI-engine\ding\torch_utils\data_helper.py", line 301, in <listcomp>
    return [to_item(d) for d in data]
  File "C:\Users\arche\code\repository\DI-engine\ding\torch_utils\data_helper.py", line 303, in to_item
    return {k: to_item(v) for k, v in data.items()}
  File "C:\Users\arche\code\repository\DI-engine\ding\torch_utils\data_helper.py", line 303, in <dictcomp>
    return {k: to_item(v) for k, v in data.items()}
  File "C:\Users\arche\code\repository\DI-engine\ding\torch_utils\data_helper.py", line 299, in to_item
    return data.item()
ValueError: only one element tensors can be converted to Python scalars

调试查看了一下 return_info 的信息:

[{'eval_episode_return': tensor([-1.2000]), 'action_args_mask': tensor([[1., 0.],
        [0., 1.],
        [0., 0.]])}, {'eval_episode_return': tensor([-1.2000]), 'action_args_mask': tensor([[1., 0.],
        [0., 1.],
        [0., 0.]])}, {'eval_episode_return': tensor([-1.2000]), 'action_args_mask': tensor([[1., 0.],
        [0., 1.],
        [0., 0.]])}, {'eval_episode_return': tensor([-1.2000]), 'action_args_mask': tensor([[1., 0.],
        [0., 1.],
        [0., 0.]])}, {'eval_episode_return': tensor([-1.2000]), 'action_args_mask': tensor([[1., 0.],
        [0., 1.],
        [0., 0.]])}]

是不是 to_item() 不支持多维的 tensor

@PaParaZz1 PaParaZz1 added bug Something isn't working config Update config labels Apr 18, 2023
@PaParaZz1
Copy link
Member

这个问题已经在最新的 main 分支 commit 中修复了,你可以看下你那边运行环境是否还存在该问题。

@xujinming01
Copy link
Author

Ok, thanks.

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

No branches or pull requests

2 participants