MeltingpotEnv¶
- torchrl.envs.MeltingpotEnv(*args, **kwargs)[原始碼]¶
Meltingpot 環境包裝器。
GitHub: https://github.com/google-deepmind/meltingpot
論文: https://arxiv.org/abs/2211.13746
Melting Pot 評估了在涉及熟悉和不熟悉個體的全新社交情境下的泛化能力,並旨在測試廣泛的社互動動,例如:合作、競爭、欺騙、互惠、信任、固執等。Melting Pot 為研究人員提供了一套超過 50 個多智慧體強化學習的底層環境(多智慧體遊戲)用於訓練智慧體,以及超過 256 個獨特的測試場景用於評估這些訓練好的智慧體。
- 引數:
substrate (str or ml_collections.config_dict.ConfigDict) – 要構建的 meltingpot 底層環境。可以是
available_envs中的字串,或者是一個底層環境的 ConfigDict- 關鍵字引數:
max_steps (int, optional) – 任務的視界。預設為
None(無限視界)。每個 Meltingpot 底層環境可以是終止的或非終止的。如果指定了max_steps,當達到此視界時,場景也將終止(並且"terminated"標誌會被設定為 True)。與 gym 的TimeLimit變換或 torchrl 的StepCounter不同,此引數不會在 tensordict 中設定"truncated"條目。categorical_actions (bool, optional) – 如果環境動作是離散的,是否將它們轉換為分類或獨熱編碼。預設為
True。group_map (MarlGroupMapType or Dict[str, List[str]], optional) – 如何在 tensordicts 中分組智慧體以用於輸入/輸出。預設情況下,它們將被全部放入一個名為
"agents"的組中。否則,可以指定組對映或從一些預製選項中選擇。有關更多資訊,請參閱MarlGroupMapType。
- 變數:
group_map (Dict[str, List[str]]) – 如何在 tensordicts 中分組智慧體以用於輸入/輸出。有關更多資訊,請參閱
MarlGroupMapType。agent_names (list of str) – 環境中智慧體的名稱
agent_names_to_indices_map (Dict[str, int]) – 將智慧體名稱對映到其在環境中的索引的字典
available_envs (List[str]) – 可用於構建的場景列表。
警告
Meltingpot 返回一個單一的
done標誌,該標誌不區分環境何時達到max_steps和何時終止。如果您認為有必要使用truncation訊號,請將max_steps設定為None並使用StepCounter變換。示例
>>> from torchrl.envs.libs.meltingpot import MeltingpotEnv >>> env_torchrl = MeltingpotEnv("commons_harvest__open") >>> print(env_torchrl.rollout(max_steps=5)) TensorDict( fields={ RGB: Tensor(shape=torch.Size([5, 144, 192, 3]), device=cpu, dtype=torch.uint8, is_shared=False), agents: TensorDict( fields={ action: Tensor(shape=torch.Size([5, 7]), device=cpu, dtype=torch.int64, is_shared=False), observation: TensorDict( fields={ COLLECTIVE_REWARD: Tensor(shape=torch.Size([5, 7, 1]), device=cpu, dtype=torch.float64, is_shared=False), READY_TO_SHOOT: Tensor(shape=torch.Size([5, 7, 1]), device=cpu, dtype=torch.float64, is_shared=False), RGB: Tensor(shape=torch.Size([5, 7, 88, 88, 3]), device=cpu, dtype=torch.uint8, is_shared=False)}, batch_size=torch.Size([5, 7]), device=cpu, is_shared=False)}, batch_size=torch.Size([5, 7]), device=cpu, is_shared=False), done: Tensor(shape=torch.Size([5, 1]), device=cpu, dtype=torch.bool, is_shared=False), next: TensorDict( fields={ RGB: Tensor(shape=torch.Size([5, 144, 192, 3]), device=cpu, dtype=torch.uint8, is_shared=False), agents: TensorDict( fields={ observation: TensorDict( fields={ COLLECTIVE_REWARD: Tensor(shape=torch.Size([5, 7, 1]), device=cpu, dtype=torch.float64, is_shared=False), READY_TO_SHOOT: Tensor(shape=torch.Size([5, 7, 1]), device=cpu, dtype=torch.float64, is_shared=False), RGB: Tensor(shape=torch.Size([5, 7, 88, 88, 3]), device=cpu, dtype=torch.uint8, is_shared=False)}, batch_size=torch.Size([5, 7]), device=cpu, is_shared=False), reward: Tensor(shape=torch.Size([5, 7, 1]), device=cpu, dtype=torch.float64, is_shared=False)}, batch_size=torch.Size([5, 7]), device=cpu, is_shared=False), done: Tensor(shape=torch.Size([5, 1]), device=cpu, dtype=torch.bool, is_shared=False), terminated: Tensor(shape=torch.Size([5, 1]), device=cpu, dtype=torch.bool, is_shared=False)}, batch_size=torch.Size([5]), device=cpu, is_shared=False), terminated: Tensor(shape=torch.Size([5, 1]), device=cpu, dtype=torch.bool, is_shared=False)}, batch_size=torch.Size([5]), device=cpu, is_shared=False)