nip.utils.torch.PairedGaussianNoise#
- class nip.utils.torch.PairedGaussianNoise(sigma: float, pair_dim: int = 0, train_sigma: bool = False, dtype=torch.float32)[source]#
Add Gaussian noise copied across the graph pair dimension.
- Parameters:
sigma (float) – The relative standard deviation of the Gaussian noise. This will be multiplied by the magnitude of the input to get the standard deviation for the noise.
pair_dim (int, default=0) – The graph pair dimension.
train_sigma (bool, default=False) – Whether the
sigma
parameter should be trained or not.
Notes
Adapted from https://discuss.pytorch.org/t/where-is-the-noise-layer-in-pytorch/2887/4
Methods Summary
__init__
(sigma[, pair_dim, train_sigma, dtype])Initialize internal Module state, shared by both nn.Module and ScriptModule.
__repr__
()Return repr(self).
forward
(x)Add Gaussian noise to the input tensor.
to
(*args, **kwargs)Move the module to a new device or dtype.
Attributes
T_destination
call_super_init
dump_patches
training
Methods
- __init__(sigma: float, pair_dim: int = 0, train_sigma: bool = False, dtype=torch.float32)[source]#
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x: Tensor) Tensor [source]#
Add Gaussian noise to the input tensor.
- Parameters:
x (Tensor) – The input tensor.
- Returns:
x_noisy (Tensor) – The input tensor with Gaussian noise added.
- to(*args, **kwargs) PairedGaussianNoise [source]#
Move the module to a new device or dtype.
- Parameters:
*args – Arguments to pass to the
to
method of the superclass.**kwargs – Keyword arguments to pass to the
to
method of the superclass.
- Returns:
self (PairedGaussianNoise) – The module itself.