def make_critic( self, features_extractor: Optional[BaseFeaturesExtractor] = None ) -> ContinuousCritic: critic_kwargs = self._update_features_extractor( self.critic_kwargs, features_extractor) return ContinuousCritic(**critic_kwargs).to(self.device)
def __init__(self, observation_space: spaces.Space, real_observation_space: spaces.Space, action_space: spaces.Space, real_action_space: spaces.Space, net_arch: List[int], features_extractor: nn.Module, features_dim: int, activation_fn: Type[nn.Module] = nn.ReLU, normalize_images: bool = True, n_critics: int = 2, share_features_extractor: bool = False, agent_num: int = 1): """ Constructor Args: observation_space: Obervation space real_observation_space: The observation space for EACH AGENT action_space: Action space real_action_spae: The action space for EACH AGENT net_arch: Network architecture features_extractor: Network to extract features (a CNN when using images, a nn.Flatten() layer otherwise) features_dim: Number of features activation_fn: Activation function normalize_images: Whether to normalize images or not, dividing by 255.0 (True by default) n_critics: Number of critic networks to create. share_features_extractor: Whether the features extractor is shared or not between the actor and the critic (this saves computation time) """ super().__init__( observation_space, action_space, features_extractor=features_extractor, normalize_images=normalize_images, ) self._critics = [ ContinuousCritic(observation_space=real_observation_space, action_space=action_space, net_arch=net_arch, features_extractor=features_extractor, features_dim=features_dim, activation_fn=activation_fn, normalize_images=normalize_images, n_critics=n_critics, share_features_extractor=False) for _ in range(agent_num) ] for idx, criticNN in enumerate(self._critics): self.add_module(f"ag_c_{idx}", criticNN)
def make_critic(self) -> ContinuousCritic: return ContinuousCritic(**self.critic_kwargs).to(self.device)