art.preprocessing.standardisation_mean_std

Standardisation Mean and Std

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

Implement the standardisation with mean and standard deviation.

__call__(x: numpy.ndarray, y: Optional[numpy.ndarray] = None) → Tuple[numpy.ndarray, Optional[numpy.ndarray]]

Apply StandardisationMeanStd inputs x.

Return type

Tuple

Parameters
  • x (ndarray) – Input samples to standardise of shapes NCHW, NHWC, NCFHW or NFHWC.

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

Returns

Standardise input samples and unmodified labels.

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

Create an instance of StandardisationMeanStd.

Parameters
  • mean (float) – Mean.

  • std (float) – Standard Deviation.

__repr__()

Return repr(self).

estimate_gradient(x: numpy.ndarray, gradient: numpy.ndarray) → numpy.ndarray

Provide an estimate of the gradients of the defence for the backward pass. If the defence is not differentiable, this is an estimate of the gradient, most often replacing the computation performed by the defence 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 – 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 = 0.0, std: float = 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 = 0.0, std: float = 1.0, apply_fit: bool = True, apply_predict: bool = True, device_type: str = 'gpu')

Create an instance of StandardisationMeanStdPyTorch.

Parameters
  • mean (float) – Mean.

  • std (float) – Standard Deviation.

__repr__()

Return repr(self).

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

Apply standardisation with mean and standard deviation to input x.

Standardisation Mean and Std - TensorFlow V2

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

Implement the standardisation with mean and standard deviation.

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

Create an instance of StandardisationMeanStdTensorFlowV2.

Parameters
  • mean (float) – Mean.

  • std (float) – Standard Deviation.

__repr__()

Return repr(self).

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

Apply standardisation with mean and standard deviation to input x.