analogvnn.nn.noise.LaplacianNoise#

Module Contents#

Classes#

LaplacianNoise

Implements the Laplacian noise function.

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

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

Implements the Laplacian noise function.

Variables:
  • scale (nn.Parameter) – the scale of the Laplacian noise.

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

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

property stddev: torch.Tensor[source]#

The standard deviation of the Laplacian noise.

Returns:

the standard deviation of the Laplacian noise.

Return type:

Tensor

property variance: torch.Tensor[source]#

The variance of the Laplacian noise.

Returns:

the variance of the Laplacian noise.

Return type:

Tensor

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

Calculate the scale of the Laplacian noise.

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

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

Returns:

the scale of the Laplacian noise.

Return type:

float

static calc_precision(scale: 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 Laplacian noise.

Parameters:
  • scale (float) – the scale of the Laplacian noise.

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

Returns:

the precision of the Laplacian noise.

Return type:

int

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

Calculate the leakage of the Laplacian noise.

Parameters:
  • scale (float) – the scale of the Laplacian noise.

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

Returns:

the leakage of the Laplacian noise.

Return type:

float

pdf(x: analogvnn.utils.common_types.TENSOR_OPERABLE, loc: analogvnn.utils.common_types.TENSOR_OPERABLE = 0) torch.Tensor[source]#

The probability density function of the Laplacian noise.

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

  • loc (TENSOR_OPERABLE) – the mean of the Laplacian noise.

Returns:

the probability density function of the Laplacian noise.

Return type:

Tensor

log_prob(x: analogvnn.utils.common_types.TENSOR_OPERABLE, loc: analogvnn.utils.common_types.TENSOR_OPERABLE = 0) torch.Tensor[source]#

The log probability density function of the Laplacian noise.

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

  • loc (TENSOR_OPERABLE) – the mean of the Laplacian noise.

Returns:

the log probability density function of the Laplacian noise.

Return type:

Tensor

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

The cumulative distribution function of the Laplacian noise.

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

  • scale (TENSOR_OPERABLE) – the scale of the Laplacian noise.

  • loc (TENSOR_OPERABLE) – the mean of the Laplacian noise.

Returns:

the cumulative distribution function of the Laplacian noise.

Return type:

TENSOR_OPERABLE

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

The cumulative distribution function of the Laplacian noise.

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

  • loc (Tensor) – the mean of the Laplacian noise.

Returns:

the cumulative distribution function of the Laplacian noise.

Return type:

Tensor

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

Add Laplacian noise to the input tensor.

Parameters:

x (Tensor) – the input tensor.

Returns:

the output tensor with Laplacian noise.

Return type:

Tensor

extra_repr() str[source]#

The extra representation of the Laplacian noise.

Returns:

the extra representation of the Laplacian noise.

Return type:

str