-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Add --namespace-packages to mypy for mlagents #3075
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
Changes from all commits
8bd70f8
5066ec6
4a42120
5939823
821639e
ea216c7
b5ebe67
f4af166
b80ca34
a930c07
4e97a7c
36e8ec8
901b791
0682eb4
1647902
86e3217
a02b1ce
828a52d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
from abc import ABC, abstractmethod | ||
from typing import List, Dict, NamedTuple, Optional | ||
from typing import List, Dict, NamedTuple | ||
from mlagents.trainers.brain import AllBrainInfo, BrainParameters | ||
from mlagents.trainers.policy import Policy | ||
from mlagents.trainers.action_info import ActionInfo | ||
|
||
|
||
class EnvironmentStep(NamedTuple): | ||
previous_all_brain_info: Optional[AllBrainInfo] | ||
previous_all_brain_info: AllBrainInfo | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good to me |
||
current_all_brain_info: AllBrainInfo | ||
brain_name_to_action_info: Optional[Dict[str, ActionInfo]] | ||
brain_name_to_action_info: Dict[str, ActionInfo] | ||
|
||
def has_actions_for_brain(self, brain_name: str) -> bool: | ||
return ( | ||
self.brain_name_to_action_info is not None | ||
and brain_name in self.brain_name_to_action_info | ||
brain_name in self.brain_name_to_action_info | ||
and self.brain_name_to_action_info[brain_name].outputs is not None | ||
) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,13 +67,14 @@ def __init__( | |
self.check_param_keys() | ||
|
||
if multi_gpu and len(get_devices()) > 1: | ||
self.policy = MultiGpuPPOPolicy( | ||
self.ppo_policy = MultiGpuPPOPolicy( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ervteng This is what we talked about offline |
||
seed, brain, trainer_parameters, self.is_training, load | ||
) | ||
else: | ||
self.policy = PPOPolicy( | ||
self.ppo_policy = PPOPolicy( | ||
seed, brain, trainer_parameters, self.is_training, load | ||
) | ||
self.policy = self.ppo_policy | ||
|
||
for _reward_signal in self.policy.reward_signals.keys(): | ||
self.collected_rewards[_reward_signal] = {} | ||
|
@@ -104,7 +105,7 @@ def process_experiences( | |
else: | ||
bootstrapping_info = next_info | ||
idx = l | ||
value_next = self.policy.get_value_estimates( | ||
value_next = self.ppo_policy.get_value_estimates( | ||
bootstrapping_info, | ||
idx, | ||
next_info.local_done[l] and not next_info.max_reached[l], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,7 @@ def __init__(self, seed, brain, trainer_parameters): | |
self.brain = brain | ||
self.use_recurrent = trainer_parameters["use_recurrent"] | ||
self.memory_dict: Dict[str, np.ndarray] = {} | ||
self.reward_signals: Dict[str, "RewardSignal"] = {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Used the string form here, because importing RewardSignal was leading to circular imports. |
||
self.num_branches = len(self.brain.vector_action_space_size) | ||
self.previous_action_dict: Dict[str, np.array] = {} | ||
self.normalize = trainer_parameters.get("normalize", False) | ||
|
@@ -126,7 +127,7 @@ def get_action(self, brain_info: BrainInfo) -> ActionInfo: | |
to be passed to add experiences | ||
""" | ||
if len(brain_info.agents) == 0: | ||
return ActionInfo([], [], None) | ||
return ActionInfo([], [], {}) | ||
|
||
agents_done = [ | ||
agent | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vincentpierre