lit_sb3.algorithms.td3.policies
source module lit_sb3.algorithms.td3.policies
Classes
-
Actor — Actor network (policy) for TD3.
-
TD3Policy — Policy class (with both actor and critic) for TD3.
-
CnnPolicy — Policy class (with both actor and critic) for TD3.
-
MultiInputPolicy — Policy class (with both actor and critic) for TD3 to be used with Dict observation spaces.
source class Actor(observation_space: spaces.Space, action_space: spaces.Box, net_arch: list[int], features_extractor: nn.Module, features_dim: int, activation_fn: type[nn.Module] = nn.ReLU, normalize_images: bool = True)
Bases : BasePolicy
Actor network (policy) for TD3.
Parameters
-
observation_space : spaces.Space — Observation space
-
action_space : spaces.Box — Action space
-
net_arch : list[int] — Network architecture
-
features_extractor : nn.Module — Network to extract features (a CNN when using images, a nn.Flatten() layer otherwise)
-
features_dim : int — Number of features
-
activation_fn : type[nn.Module] — Activation function
-
normalize_images : bool — Whether to normalize images or not, dividing by 255.0 (True by default)
Attributes
-
device : torch.device — Infer which device this policy lives on by inspecting its parameters.
-
squash_output : bool — (bool) Getter for squash_output.
Methods
source method Actor.forward(obs: torch.Tensor) → torch.Tensor
source class TD3Policy(observation_space: spaces.Space, action_space: spaces.Box, lr_schedule: Schedule, net_arch: list[int] | dict[str, list[int]] | None = None, activation_fn: type[nn.Module] = nn.ReLU, features_extractor_class: type[BaseFeaturesExtractor] = FlattenExtractor, features_extractor_kwargs: dict[str, Any] | None = None, normalize_images: bool = True, optimizer_class: type[torch.optim.Optimizer] = torch.optim.Adam, optimizer_kwargs: dict[str, Any] | None = None, n_critics: int = 2, share_features_extractor: bool = False)
Bases : BasePolicy
Policy class (with both actor and critic) for TD3.
Parameters
-
observation_space : spaces.Space — Observation space
-
action_space : spaces.Box — Action space
-
lr_schedule : Schedule — Learning rate schedule (could be constant)
-
net_arch : list[int] | dict[str, list[int]] | None — The specification of the policy and value networks.
-
activation_fn : type[nn.Module] — Activation function
-
features_extractor_class : type[BaseFeaturesExtractor] — Features extractor to use.
-
features_extractor_kwargs : dict[str, Any] | None — Keyword arguments to pass to the features extractor.
-
normalize_images : bool — Whether to normalize images or not, dividing by 255.0 (True by default)
-
optimizer_class : type[torch.optim.Optimizer] — The optimizer to use,
torch.optim.Adamby default -
optimizer_kwargs : dict[str, Any] | None — Additional keyword arguments, excluding the learning rate, to pass to the optimizer
-
n_critics : int — Number of critic networks to create.
-
share_features_extractor : bool — Whether to share or not the features extractor between the actor and the critic (this saves computation time)
Attributes
-
device : torch.device — Infer which device this policy lives on by inspecting its parameters.
-
squash_output : bool — (bool) Getter for squash_output.
Methods
-
set_training_mode — Put the policy in either training or evaluation mode.
source method TD3Policy.make_actor(features_extractor: BaseFeaturesExtractor | None = None) → Actor
source method TD3Policy.make_critic(features_extractor: BaseFeaturesExtractor | None = None) → ContinuousCritic
source method TD3Policy.forward(observation: PyTorchObs, deterministic: bool = False) → torch.Tensor
source method TD3Policy.set_training_mode(mode: bool) → None
Put the policy in either training or evaluation mode.
This affects certain modules, such as batch normalisation and dropout.
Parameters
-
mode : bool — if true, set to training mode, else set to evaluation mode
source class CnnPolicy(observation_space: spaces.Space, action_space: spaces.Box, lr_schedule: Schedule, net_arch: list[int] | dict[str, list[int]] | None = None, activation_fn: type[nn.Module] = nn.ReLU, features_extractor_class: type[BaseFeaturesExtractor] = NatureCNN, features_extractor_kwargs: dict[str, Any] | None = None, normalize_images: bool = True, optimizer_class: type[torch.optim.Optimizer] = torch.optim.Adam, optimizer_kwargs: dict[str, Any] | None = None, n_critics: int = 2, share_features_extractor: bool = False)
Bases : TD3Policy
Policy class (with both actor and critic) for TD3.
Parameters
-
observation_space : spaces.Space — Observation space
-
action_space : spaces.Box — Action space
-
lr_schedule : Schedule — Learning rate schedule (could be constant)
-
net_arch : list[int] | dict[str, list[int]] | None — The specification of the policy and value networks.
-
activation_fn : type[nn.Module] — Activation function
-
features_extractor_class : type[BaseFeaturesExtractor] — Features extractor to use.
-
features_extractor_kwargs : dict[str, Any] | None — Keyword arguments to pass to the features extractor.
-
normalize_images : bool — Whether to normalize images or not, dividing by 255.0 (True by default)
-
optimizer_class : type[torch.optim.Optimizer] — The optimizer to use,
torch.optim.Adamby default -
optimizer_kwargs : dict[str, Any] | None — Additional keyword arguments, excluding the learning rate, to pass to the optimizer
-
n_critics : int — Number of critic networks to create.
-
share_features_extractor : bool — Whether to share or not the features extractor between the actor and the critic (this saves computation time)
Attributes
-
device : torch.device — Infer which device this policy lives on by inspecting its parameters.
-
squash_output : bool — (bool) Getter for squash_output.
source class MultiInputPolicy(observation_space: spaces.Dict, action_space: spaces.Box, lr_schedule: Schedule, net_arch: list[int] | dict[str, list[int]] | None = None, activation_fn: type[nn.Module] = nn.ReLU, features_extractor_class: type[BaseFeaturesExtractor] = CombinedExtractor, features_extractor_kwargs: dict[str, Any] | None = None, normalize_images: bool = True, optimizer_class: type[torch.optim.Optimizer] = torch.optim.Adam, optimizer_kwargs: dict[str, Any] | None = None, n_critics: int = 2, share_features_extractor: bool = False)
Bases : TD3Policy
Policy class (with both actor and critic) for TD3 to be used with Dict observation spaces.
Parameters
-
observation_space : spaces.Dict — Observation space
-
action_space : spaces.Box — Action space
-
lr_schedule : Schedule — Learning rate schedule (could be constant)
-
net_arch : list[int] | dict[str, list[int]] | None — The specification of the policy and value networks.
-
activation_fn : type[nn.Module] — Activation function
-
features_extractor_class : type[BaseFeaturesExtractor] — Features extractor to use.
-
features_extractor_kwargs : dict[str, Any] | None — Keyword arguments to pass to the features extractor.
-
normalize_images : bool — Whether to normalize images or not, dividing by 255.0 (True by default)
-
optimizer_class : type[torch.optim.Optimizer] — The optimizer to use,
torch.optim.Adamby default -
optimizer_kwargs : dict[str, Any] | None — Additional keyword arguments, excluding the learning rate, to pass to the optimizer
-
n_critics : int — Number of critic networks to create.
-
share_features_extractor : bool — Whether to share or not the features extractor between the actor and the critic (this saves computation time)
Attributes
-
device : torch.device — Infer which device this policy lives on by inspecting its parameters.
-
squash_output : bool — (bool) Getter for squash_output.