Unity/mlagents,用正确的论据为多个大脑打电话

2024-04-23 14:35:54 发布

您现在位置:Python中文网/ 问答频道 /正文

This。我可以成功地训练1个大脑,但当我想训练2个大脑时,我会出现以下错误

---------------------------------------------------------------------------
UnityActionException                      Traceback (most recent call last)
<ipython-input-4-520c26ebec47> in <module>()
     48 
     49 
---> 50         new_info = trainer.take_action(info, env, brain_name)
     51 
     52 

C:\UNITY\ml-agents-master\python\ppo\trainer.py in take_action(self, info, env, brain_name)
     51         self.stats['value_estimate'].append(value)
     52         self.stats['entropy'].append(ent)
---> 53         new_info = env.step(actions, value={brain_name: value})[brain_name]
     54         self.add_experiences(info, new_info, epsi, actions, a_dist, value)
     55         return new_info

C:\UNITY\ml-agents-master\python\unityagents\environment.py in step(self, action, memory, value)
    288                     raise UnityActionException(
    289                         "You have {0} brains, you need to feed a dictionary of brain names a keys, "
--> 290                         "and actions as values".format(self._num_brains))
    291                 else:
    292                     action = {self._brain_names[0]: action}

UnityActionException: You have 2 brains, you need to feed a dictionary of brain names a keys, and actions as values

Here我找到了与我的问题相关的部分:

Step : env.step(action, memory=None, value = None)

Sends a step signal to the environment using the actions. Note that if you have more than one brain in the environment, you must provide a dictionary from brain names to actions.

  • action can be one dimensional arrays or two dimensional arrays if you have multiple agents per brains.

  • memory is an optional input that can be used to send a list of floats per agents to be retrieved at the next step.

  • value is an optional input that be used to send a single float per agent to be displayed if and AgentMonitor.cs component is attached to the agent. Returns a dictionary mapping brain names to BrainInfo objects.

但我不知道该怎么解释。 有人能建议我应该如何构建它,以便在我的环境中使用两个大脑?在

谢谢!在


Tags: thetoinselfinfoenvyouactions
1条回答
网友
1楼 · 发布于 2024-04-23 14:35:54

如果你只有一个大脑,你可以输入一个列表或一个浮点数数组。在

如果你有多个大脑,你必须寄一本字典。在

示例:如果您有两个大脑( 'brain1' and 'brain2')每个大脑都有一个执行2个连续操作的代理,则必须调用:env.step({'brain1':[0.1,0.2], 'brain2':[0.3,0.4]})

相关问题 更多 >