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: Union[float, ndarray] = 0.0, std: Union[float, ndarray] = 1.0, apply_fit: bool = True, apply_predict: bool = True)¶
Implement the standardisation with mean and standard deviation.
- __call__(x: ndarray, y: Optional[ndarray] = None) Tuple[ndarray, Optional[ndarray]] ¶
Apply StandardisationMeanStd inputs x.
- Return type
Tuple
- 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: Union[float, ndarray] = 0.0, std: Union[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: Union[float, ndarray] = 0.0, std: Union[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: Union[float, ndarray] = 0.0, std: Union[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: Optional[torch.Tensor] = None) Tuple[torch.Tensor, Optional[torch.Tensor]] ¶
Apply standardisation with mean and standard deviation to input x.
- Return type
Tuple
- 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: Union[float, ndarray] = 0.0, std: Union[float, ndarray] = 1.0, apply_fit: bool = True, apply_predict: bool = True)¶
Implement the standardisation with mean and standard deviation.
- __init__(mean: Union[float, ndarray] = 0.0, std: Union[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: Optional[tf.Tensor] = None) Tuple[tf.Tensor, Optional[tf.Tensor]] ¶
Apply standardisation with mean and standard deviation to input x.
- Return type
Tuple
- Parameters
x – Input samples to standardise.
y – Label data, will not be affected by this preprocessing.
- Returns
Standardised input samples and unmodified labels.