analogvnn.nn.noise.GaussianNoise#

Module Contents#

Classes#

GaussianNoise

Implements the Gaussian noise function.

class analogvnn.nn.noise.GaussianNoise.GaussianNoise(std: Optional[float] = None, leakage: Optional[float] = None, precision: Optional[int] = None)[source]#

Bases: analogvnn.nn.noise.Noise.Noise, analogvnn.backward.BackwardIdentity.BackwardIdentity

Implements the Gaussian noise function.

Variables:
  • std (nn.Parameter) – the standard deviation of the Gaussian noise.

  • leakage (nn.Parameter) – the leakage of the Gaussian noise.

  • precision (nn.Parameter) – the precision of the Gaussian noise.

property stddev: torch.Tensor[source]#

The standard deviation of the Gaussian noise.

Returns:

the standard deviation of the Gaussian noise.

Return type:

Tensor

property variance: torch.Tensor[source]#

The variance of the Gaussian noise.

Returns:

the variance of the Gaussian noise.

Return type:

Tensor

__constants__ = ['std', 'leakage', 'precision'][source]#
std: torch.nn.Parameter[source]#
leakage: torch.nn.Parameter[source]#
precision: torch.nn.Parameter[source]#
static calc_std(leakage: analogvnn.utils.common_types.TENSOR_OPERABLE, precision: analogvnn.utils.common_types.TENSOR_OPERABLE) analogvnn.utils.common_types.TENSOR_OPERABLE[source]#

Calculate the standard deviation of the Gaussian noise.

Parameters:
  • leakage (float) – the leakage of the Gaussian noise.

  • precision (int) – the precision of the Gaussian noise.

Returns:

the standard deviation of the Gaussian noise.

Return type:

float

static calc_precision(std: analogvnn.utils.common_types.TENSOR_OPERABLE, leakage: analogvnn.utils.common_types.TENSOR_OPERABLE) analogvnn.utils.common_types.TENSOR_OPERABLE[source]#

Calculate the precision of the Gaussian noise.

Parameters:
  • std (float) – the standard deviation of the Gaussian noise.

  • leakage (float) – the leakage of the Gaussian noise.

Returns:

the precision of the Gaussian noise.

Return type:

int

static calc_leakage(std: analogvnn.utils.common_types.TENSOR_OPERABLE, precision: analogvnn.utils.common_types.TENSOR_OPERABLE) analogvnn.utils.common_types.TENSOR_OPERABLE[source]#

Calculate the leakage of the Gaussian noise.

Parameters:
  • std (float) – the standard deviation of the Gaussian noise.

  • precision (int) – the precision of the Gaussian noise.

Returns:

the leakage of the Gaussian noise.

Return type:

float

pdf(x: torch.Tensor, mean: torch.Tensor = 0) torch.Tensor[source]#

Calculate the probability density function of the Gaussian noise.

Parameters:
  • x (Tensor) – the input tensor.

  • mean (Tensor) – the mean of the Gaussian noise.

Returns:

the probability density function of the Gaussian noise.

Return type:

Tensor

log_prob(x: torch.Tensor, mean: torch.Tensor = 0) torch.Tensor[source]#

Calculate the log probability density function of the Gaussian noise.

Parameters:
  • x (Tensor) – the input tensor.

  • mean (Tensor) – the mean of the Gaussian noise.

Returns:

the log probability density function of the Gaussian noise.

Return type:

Tensor

static static_cdf(x: analogvnn.utils.common_types.TENSOR_OPERABLE, std: analogvnn.utils.common_types.TENSOR_OPERABLE, mean: analogvnn.utils.common_types.TENSOR_OPERABLE = 0.0) analogvnn.utils.common_types.TENSOR_OPERABLE[source]#

Calculate the cumulative distribution function of the Gaussian noise.

Parameters:
  • x (TENSOR_OPERABLE) – the input tensor.

  • std (TENSOR_OPERABLE) – the standard deviation of the Gaussian noise.

  • mean (TENSOR_OPERABLE) – the mean of the Gaussian noise.

Returns:

the cumulative distribution function of the Gaussian noise.

Return type:

TENSOR_OPERABLE

cdf(x: torch.Tensor, mean: torch.Tensor = 0) torch.Tensor[source]#

Calculate the cumulative distribution function of the Gaussian noise.

Parameters:
  • x (Tensor) – the input tensor.

  • mean (Tensor) – the mean of the Gaussian noise.

Returns:

the cumulative distribution function of the Gaussian noise.

Return type:

Tensor

forward(x: torch.Tensor) torch.Tensor[source]#

Add the Gaussian noise to the input tensor.

Parameters:

x (Tensor) – the input tensor.

Returns:

the output tensor.

Return type:

Tensor

extra_repr() str[source]#

The extra representation of the Gaussian noise.

Returns:

the extra representation of the Gaussian noise.

Return type:

str