NoisyLazyLinear#
- class torchrl.modules.NoisyLazyLinear(out_features: int, bias: bool = True, device: device | str | int | None = None, dtype: dtype | None = None, std_init: float = 0.5, use_exploration_type: bool | None = True)[source]#
Noisy Lazy Linear Layer.
This class makes the Noisy Linear layer lazy, in that the in_feature argument does not need to be passed at initialization (but is inferred after the first call to the layer).
For more context on noisy layers, see the NoisyLinear class. Like
NoisyLinear, noise is sampled only byreset_noise()(at materialization) and must be reapplied by the caller.- Parameters:
out_features (int) – out features dimension
bias (bool, optional) – if
True, a bias term will be added to the matrix multiplication: Ax + b. Defaults toTrue.device (DEVICE_TYPING, optional) – device of the layer. Defaults to
"cpu".dtype (torch.dtype, optional) – dtype of the parameters. Defaults to the default PyTorch dtype.
std_init (scalar) – initial value of the Gaussian standard deviation before optimization. Defaults to
0.5as per the original paper.use_exploration_type (bool or None, optional) – if
True, noise is controlled byexploration_type(). IfFalse, noise is controlled byself.training(legacy behavior). IfNone, it is treated asTrue. Defaults toTrue.
- cls_to_become#
alias of
NoisyLinear
- initialize_parameters(input: Tensor) None[source]#
Initialize parameters according to the input batch properties.
This adds an interface to isolate parameter initialization from the forward pass when doing parameter shape inference.