art.preprocessing.standardisation_mean_std

This module contains tool for input standardisation with mean and standard deviation.

Standardisation Mean and Std

class art.preprocessing.standardisation_mean_std.StandardisationMeanStd(mean: float | ndarray = 0.0, std: float | ndarray = 1.0, apply_fit: bool = True, apply_predict: bool = True)

Implement the standardisation with mean and standard deviation.

__call__(x: ndarray, y: ndarray | None = None) Tuple[ndarray, ndarray | None]

Apply StandardisationMeanStd inputs x.

Parameters:
  • x (ndarray) – Input samples to standardise.

  • y – Label data, will not be affected by this preprocessing.

Returns:

Standardise input samples and unmodified labels.

__init__(mean: float | ndarray = 0.0, std: float | ndarray = 1.0, apply_fit: bool = True, apply_predict: bool = True)

Create an instance of StandardisationMeanStd.

Parameters:
  • mean – Mean.

  • std – Standard Deviation.

__repr__()

Return repr(self).

estimate_gradient(x: ndarray, grad: ndarray) ndarray

Provide an estimate of the gradients of preprocessor for the backward pass. If the preprocessor is not differentiable, this is an estimate of the gradient, most often replacing the computation performed by the preprocessor with the identity function (the default).

Return type:

ndarray

Parameters:
  • x (ndarray) – Input data for which the gradient is estimated. First dimension is the batch size.

  • grad (ndarray) – Gradient value so far.

Returns:

The gradient (estimate) of the defence.

Standardisation Mean and Std - PyTorch

class art.preprocessing.standardisation_mean_std.StandardisationMeanStdPyTorch(mean: float | ndarray = 0.0, std: float | ndarray = 1.0, apply_fit: bool = True, apply_predict: bool = True, device_type: str = 'gpu')

Implement the standardisation with mean and standard deviation.

__init__(mean: float | ndarray = 0.0, std: float | ndarray = 1.0, apply_fit: bool = True, apply_predict: bool = True, device_type: str = 'gpu')

Create an instance of StandardisationMeanStdPyTorch.

Parameters:
  • mean – Mean.

  • std – Standard Deviation.

__repr__()

Return repr(self).

forward(x: torch.Tensor, y: torch.Tensor | None = None) Tuple[torch.Tensor, torch.Tensor | None]

Apply standardisation with mean and standard deviation to input x.

Parameters:
  • x – Input samples to standardise.

  • y – Label data, will not be affected by this preprocessing.

Returns:

Standardised input samples and unmodified labels.

Standardisation Mean and Std - TensorFlow V2

class art.preprocessing.standardisation_mean_std.StandardisationMeanStdTensorFlow(mean: float | ndarray = 0.0, std: float | ndarray = 1.0, apply_fit: bool = True, apply_predict: bool = True)

Implement the standardisation with mean and standard deviation.

__init__(mean: float | ndarray = 0.0, std: float | ndarray = 1.0, apply_fit: bool = True, apply_predict: bool = True)

Create an instance of StandardisationMeanStdTensorFlow.

Parameters:
  • mean – Mean.

  • std – Standard Deviation.

__repr__()

Return repr(self).

forward(x: tf.Tensor, y: tf.Tensor | None = None) Tuple[tf.Tensor, tf.Tensor | None]

Apply standardisation with mean and standard deviation to input x.

Parameters:
  • x – Input samples to standardise.

  • y – Label data, will not be affected by this preprocessing.

Returns:

Standardised input samples and unmodified labels.