forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RLlib] IMPALA/APPO multi-agent mix-in-buffer fixes (plus MA learning…
… tests). (ray-project#25848)
- Loading branch information
1 parent
1c27469
commit a322cc5
Showing
12 changed files
with
257 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from ray.rllib.models.catalog import ModelCatalog | ||
from ray.rllib.models.modelv2 import ModelV2 | ||
|
||
|
||
POLICY_SCOPE = "func" | ||
TARGET_POLICY_SCOPE = "target_func" | ||
|
||
|
||
def make_appo_models(policy) -> ModelV2: | ||
"""Builds model and target model for APPO. | ||
Returns: | ||
ModelV2: The Model for the Policy to use. | ||
Note: The target model will not be returned, just assigned to | ||
`policy.target_model`. | ||
""" | ||
# Get the num_outputs for the following model construction calls. | ||
_, logit_dim = ModelCatalog.get_action_dist( | ||
policy.action_space, policy.config["model"] | ||
) | ||
|
||
# Construct the (main) model. | ||
policy.model = ModelCatalog.get_model_v2( | ||
policy.observation_space, | ||
policy.action_space, | ||
logit_dim, | ||
policy.config["model"], | ||
name=POLICY_SCOPE, | ||
framework=policy.framework, | ||
) | ||
policy.model_variables = policy.model.variables() | ||
|
||
# Construct the target model. | ||
policy.target_model = ModelCatalog.get_model_v2( | ||
policy.observation_space, | ||
policy.action_space, | ||
logit_dim, | ||
policy.config["model"], | ||
name=TARGET_POLICY_SCOPE, | ||
framework=policy.framework, | ||
) | ||
policy.target_model_variables = policy.target_model.variables() | ||
|
||
# Return only the model (not the target model). | ||
return policy.model |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.