openrl.modules.networks.utils package¶
Subpackages¶
Submodules¶
openrl.modules.networks.utils.act module¶
- class openrl.modules.networks.utils.act.ACTLayer(action_space, inputs_dim, use_orthogonal, gain)[source]¶
Bases:
torch.nn.modules.module.Module- forward(x, action_masks=None, deterministic=False)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
openrl.modules.networks.utils.attention module¶
- class openrl.modules.networks.utils.attention.CatSelfEmbedding(split_shape, d_model, use_orthogonal=True, activation_id=1)[source]¶
Bases:
torch.nn.modules.module.Module- forward(x, self_idx=- 1)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class openrl.modules.networks.utils.attention.Embedding(split_shape, d_model, use_orthogonal=True, activation_id=1)[source]¶
Bases:
torch.nn.modules.module.Module- forward(x, self_idx=None)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class openrl.modules.networks.utils.attention.Encoder(cfg, split_shape, cat_self=True)[source]¶
Bases:
torch.nn.modules.module.Module- forward(x, self_idx=- 1, mask=None)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class openrl.modules.networks.utils.attention.EncoderLayer(d_model, heads, dropout=0.0, use_orthogonal=True, activation_id=False, d_ff=512, use_FF=False)[source]¶
Bases:
torch.nn.modules.module.Module- forward(x, mask)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class openrl.modules.networks.utils.attention.FeedForward(d_model, d_ff=512, dropout=0.0, use_orthogonal=True, activation_id=1)[source]¶
Bases:
torch.nn.modules.module.Module- forward(x)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class openrl.modules.networks.utils.attention.MultiHeadAttention(heads, d_model, dropout=0.0, use_orthogonal=True)[source]¶
Bases:
torch.nn.modules.module.Module- forward(q, k, v, mask=None)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
openrl.modules.networks.utils.cnn module¶
- class openrl.modules.networks.utils.cnn.CNNBase(cfg, obs_shape)[source]¶
Bases:
torch.nn.modules.module.Module- forward(x)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- property output_size¶
- class openrl.modules.networks.utils.cnn.CNNLayer(obs_shape, hidden_size, use_orthogonal, activation_id, kernel_size=3, stride=1)[source]¶
Bases:
torch.nn.modules.module.Module- forward(x)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class openrl.modules.networks.utils.cnn.Flatten(*args, **kwargs)[source]¶
Bases:
torch.nn.modules.module.Module- forward(x)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
openrl.modules.networks.utils.distributed_utils module¶
openrl.modules.networks.utils.distributions module¶
- class openrl.modules.networks.utils.distributions.AddBias(bias)[source]¶
Bases:
torch.nn.modules.module.Module- forward(x)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class openrl.modules.networks.utils.distributions.Bernoulli(num_inputs, num_outputs, use_orthogonal=True, gain=0.01)[source]¶
Bases:
torch.nn.modules.module.Module- forward(x)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class openrl.modules.networks.utils.distributions.Categorical(num_inputs, num_outputs, use_orthogonal=True, gain=0.01)[source]¶
Bases:
torch.nn.modules.module.Module- forward(x, action_masks=None)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class openrl.modules.networks.utils.distributions.DiagGaussian(num_inputs, num_outputs, use_orthogonal=True, gain=0.01)[source]¶
Bases:
torch.nn.modules.module.Module- forward(x)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class openrl.modules.networks.utils.distributions.FixedBernoulli(probs=None, logits=None, validate_args=None)[source]¶
Bases:
torch.distributions.bernoulli.Bernoulli
- class openrl.modules.networks.utils.distributions.FixedCategorical(probs=None, logits=None, validate_args=None)[source]¶
Bases:
torch.distributions.categorical.Categorical
openrl.modules.networks.utils.mix module¶
- class openrl.modules.networks.utils.mix.Flatten(*args, **kwargs)[source]¶
Bases:
torch.nn.modules.module.Module- forward(x)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class openrl.modules.networks.utils.mix.MIXBase(cfg, obs_shape, cnn_layers_params=None)[source]¶
Bases:
torch.nn.modules.module.Module- forward(x)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- property output_size¶
openrl.modules.networks.utils.mlp module¶
- class openrl.modules.networks.utils.mlp.CONVLayer(input_dim, hidden_size, use_orthogonal, activation_id)[source]¶
Bases:
torch.nn.modules.module.Module- forward(x)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class openrl.modules.networks.utils.mlp.MLPBase(cfg, obs_shape, use_attn_internal=False, use_cat_self=True)[source]¶
Bases:
torch.nn.modules.module.Module- forward(x)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- property output_size¶
- class openrl.modules.networks.utils.mlp.MLPLayer(input_dim, hidden_size, layer_N, use_orthogonal, activation_id)[source]¶
Bases:
torch.nn.modules.module.Module- forward(x)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
openrl.modules.networks.utils.popart module¶
- class openrl.modules.networks.utils.popart.PopArt(input_shape, output_shape, norm_axes=1, beta=0.99999, epsilon=1e-05, device=device(type='cpu'))[source]¶
Bases:
torch.nn.modules.module.Module- forward(input_vector)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
openrl.modules.networks.utils.rnn module¶
- class openrl.modules.networks.utils.rnn.RNNLayer(inputs_dim, outputs_dim, recurrent_N, use_orthogonal, rnn_type='gru')[source]¶
Bases:
torch.nn.modules.module.Module- forward(x, hxs, masks)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
openrl.modules.networks.utils.running_mean_std module¶
- class openrl.modules.networks.utils.running_mean_std.RunningMeanStd(epsilon: float = 0.0001, shape: Tuple[int, ...] = ())[source]¶
Bases:
object- combine(other: openrl.modules.networks.utils.running_mean_std.RunningMeanStd) None[source]¶
Combine stats from another
RunningMeanStdobject.- Parameters
other – The other object to combine with.
- copy() openrl.modules.networks.utils.running_mean_std.RunningMeanStd[source]¶
- Returns
Return a copy of the current object.
openrl.modules.networks.utils.transformer_act module¶
- openrl.modules.networks.utils.transformer_act.continuous_autoregreesive_act(decoder, obs_rep, obs, batch_size, n_agent, action_dim, tpdv, deterministic=False)[source]¶
- openrl.modules.networks.utils.transformer_act.continuous_parallel_act(decoder, obs_rep, obs, action, batch_size, n_agent, action_dim, tpdv)[source]¶
openrl.modules.networks.utils.util module¶
openrl.modules.networks.utils.vdn module¶
- class openrl.modules.networks.utils.vdn.VDNBase[source]¶
Bases:
torch.nn.modules.module.Module- forward(agent_qs)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.