opendilab / DI-engine

OpenDILab Decision AI Engine
https://di-engine-docs.readthedocs.io
Apache License 2.0
2.79k stars 348 forks source link

get "TypeError: __init__() got an unexpected keyword argument 'agent_obs_shape'" when running " python3 -u smac_5m6m_masac_config.py" #791

Closed SiriusZbz closed 2 months ago

SiriusZbz commented 2 months ago

root@I196082a51d0070168c:/hy-tmp/DI-engine/dizoo/smac/config# python3 -u smac_5m6m_masac_config.py [04-15 20:32:26] WARNING If you want to use numba to speed up segment tree, please install numba first default_helper.py:450 [04-15 20:32:27] WARNING not found transformer, please install it using: pip install transformers language_transformer.py:9 difficulty 7 difficulty 7 Hint: for <class 'ding.model.template.qac.DiscreteQAC'>(alias=discrete_qac)

Expected args are: FullArgSpec(args=['self', 'obs_shape', 'action_shape', 'twin_critic', 'actor_head_hidden_size', 'actor_head_layer_num', 'critic_head_hidden_size', 'critic_head_layer_num', 'activation', 'norm_type', 'encoder_hidden_size_list', 'share_encoder'], varargs=None, varkw=None, defaults=(False, 64, 1, 64, 1, ReLU(), None, None, False), kwonlyargs=[], kwonlydefaults=None, annotations={'return': None, 'obs_shape': typing.Union[int, ~SequenceType], 'action_shape': typing.Union[int, ~SequenceType], 'twin_critic': <class 'bool'>, 'actor_head_hidden_size': <class 'int'>, 'actor_head_layer_num': <class 'int'>, 'critic_head_hidden_size': <class 'int'>, 'critic_head_layer_num': <class 'int'>, 'activation': typing.Union[torch.nn.modules.module.Module, NoneType], 'norm_type': typing.Union[str, NoneType], 'encoder_hidden_size_list': ~SequenceType, 'share_encoder': typing.Union[bool, NoneType]}) Given arguments keys are: dict_keys(['twin_critic', 'agent_obs_shape', 'global_obs_shape', 'action_shape', 'actor_head_hidden_size', 'critic_head_hidden_size'])

Traceback (most recent call last): File "smac_5m6m_masac_config.py", line 89, in serial_pipeline((main_config, create_config), seed=0) File "/usr/local/lib/python3.8/dist-packages/ding/entry/serial_entry.py", line 61, in serial_pipeline policy = create_policy(cfg.policy, model=model, enable_field=['learn', 'collect', 'eval', 'command']) File "/usr/local/lib/python3.8/dist-packages/ding/policy/base_policy.py", line 844, in create_policy return POLICY_REGISTRY.build(cfg.type, cfg=cfg, kwargs) File "/usr/local/lib/python3.8/dist-packages/ding/utils/registry.py", line 144, in build raise e File "/usr/local/lib/python3.8/dist-packages/ding/utils/registry.py", line 129, in build return build_fn(obj_args, obj_kwargs) File "/usr/local/lib/python3.8/dist-packages/ding/policy/base_policy.py", line 134, in init model = self._create_model(cfg, model) File "/usr/local/lib/python3.8/dist-packages/ding/policy/base_policy.py", line 219, in _create_model return create_model(model_cfg) File "/usr/local/lib/python3.8/dist-packages/ding/model/common/utils.py", line 31, in create_model return MODEL_REGISTRY.build(cfg.pop("type"), cfg) File "/usr/local/lib/python3.8/dist-packages/ding/utils/registry.py", line 144, in build raise e File "/usr/local/lib/python3.8/dist-packages/ding/utils/registry.py", line 129, in build return build_fn(obj_args, obj_kwargs) TypeError: init() got an unexpected keyword argument 'agent_obs_shape'

PaParaZz1 commented 2 months ago

You need to add multi_agent=True in your used config, such as:

    policy=dict(
        cuda=True,
        multi_agent=True,
        ...
     )

Here is the concrete implementation. (link)

And we will fix this bug in the following updates.

SiriusZbz commented 2 months ago

Thank you,it works!