lit_sb3.algorithms.dqn.policies
source module lit_sb3.algorithms.dqn.policies
Classes
-
QNetwork — Action-Value (Q-Value) network for DQN.
-
DQNPolicy — Policy class with Q-Value Net and target net for DQN.
-
CnnPolicy — Policy class for DQN when using images as input.
-
MultiInputPolicy — Policy class for DQN when using dict observations as input.
source class QNetwork(observation_space: spaces.Space, action_space: spaces.Discrete, features_extractor: BaseFeaturesExtractor, features_dim: int, net_arch: list[int] | None = None, activation_fn: type[nn.Module] = nn.ReLU, normalize_images: bool = True)
Bases : BasePolicy
Action-Value (Q-Value) network for DQN.
Parameters
-
observation_space : spaces.Space — Observation space
-
action_space : spaces.Discrete — Action space
-
net_arch : list[int] | None — The specification of the policy and value networks.
-
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
-
forward — Predict the q-values.
source method QNetwork.forward(obs: PyTorchObs) → torch.Tensor
Predict the q-values.
Parameters
-
obs : PyTorchObs — Observation
Returns
-
torch.Tensor — The estimated Q-Value for each action.
source class DQNPolicy(observation_space: spaces.Space, action_space: spaces.Discrete, lr_schedule: Schedule, net_arch: 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)
Bases : BasePolicy
Policy class with Q-Value Net and target net for DQN.
Parameters
-
observation_space : spaces.Space — Observation space
-
action_space : spaces.Discrete — Action space
-
lr_schedule : Schedule — Learning rate schedule (could be constant)
-
net_arch : 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
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 DQNPolicy.make_q_net() → QNetwork
source method DQNPolicy.forward(obs: PyTorchObs, deterministic: bool = True) → torch.Tensor
source method DQNPolicy.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.Discrete, lr_schedule: Schedule, net_arch: 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)
Bases : DQNPolicy
Policy class for DQN when using images as input.
Parameters
-
observation_space : spaces.Space — Observation space
-
action_space : spaces.Discrete — Action space
-
lr_schedule : Schedule — Learning rate schedule (could be constant)
-
net_arch : 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.
-
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
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.Discrete, lr_schedule: Schedule, net_arch: 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)
Bases : DQNPolicy
Policy class for DQN when using dict observations as input.
Parameters
-
observation_space : spaces.Dict — Observation space
-
action_space : spaces.Discrete — Action space
-
lr_schedule : Schedule — Learning rate schedule (could be constant)
-
net_arch : 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.
-
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
Attributes
-
device : torch.device — Infer which device this policy lives on by inspecting its parameters.
-
squash_output : bool — (bool) Getter for squash_output.