Transforms#
Classes#
- class BaseTransform[source]#
Bases:
ABC,Generic[InArrayCT,OutArrayCT]Base transformation class that other types of transforms build from.
- __call__(x, *, back=False, uncertainty=None)[source]#
Calling function returns the forward, backwards or uncertainty propagation of the transformation
- Overloads:
- __call__(self, x: InArrayCT, *, back: bool = ...) OutArrayCT
- __call__(self, x: Data[InArrayCT], *, back: bool = ...) Data[OutArrayCT]
- __call__(self, x: InArrayCT, *, back: bool = ..., uncertainty: InArrayCT) tuple[OutArrayCT, OutArrayCT]
- Parameters:
- Returns:
- abstractmethod backward_grad(x, uncertainty)[source]#
Backwards pass to invert the transformation and uncertainty propagation
- extra_repr()[source]#
Additional representation of the transformation
- Returns:
strTransform specific representation
- class BaseTypeTransform[source]#
Bases:
BaseTransform[ArrayCT,ArrayCT]Base transformation class that other types of transforms build from, with the same input and output type.
- backward_grad(x, uncertainty)[source]#
Backwards pass to invert the transformation and uncertainty propagation
- class Index(*, dim=-1, in_shape=None, slice_=slice(None, None, None))[source]#
Bases:
BaseTypeTransformSlices the input along a given dimension assuming the input meets the required shape.
- Parameters:
- dim
int,Optional Dimension to slice over, default = -1
- in_shape
tuple[int, …] |NoneType,Optional Target shape ignoring batch size so that the slice only occurs if the input has the same shape to prevent repeated slicing, if any dimension has a shape of -1, then the size of the dimension will be ignored
- slice_
slice,Optional Slicing object, default = slice(None)
- dim
- extra_repr()[source]#
Additional representation of the transformation
- Returns:
strTransform specific representation
- class Log(*, base=10, idxs=None)[source]#
Bases:
BaseTypeTransformLogarithm transform.
- Parameters:
- backward_grad(x, uncertainty)[source]#
Backwards pass to invert the transformation and uncertainty propagation
- extra_repr()[source]#
Additional representation of the transformation
- Returns:
strTransform specific representation
- class MinClamp(*, dim=None, idxs=None)[source]#
Bases:
BaseTypeTransformClamps the minimum value to be the smallest positive value.
- Parameters:
- class MultiTransform(*args)[source]#
Bases:
BaseTransformApplies multiple transformations.
- Attributes:
- transforms
list[BaseTransform] List of transformations
- transforms
- Parameters:
- *args
BaseTransform Transformations
- *args
- __getitem__(item)[source]#
Gets a transform or a slice of transforms from the list of transforms.
- Overloads:
- __getitem__(self, item: int) BaseTransform
- __getitem__(self, item: slice) MultiTransform
- Parameters:
- Returns:
BaseTransformTransform or MultiTransform containing the slice of transforms
- append(transform)[source]#
Appends a transform to the list of transforms
- Parameters:
- transform
BaseTransform Transform to append to the list of transforms
- transform
- backward_grad(x, uncertainty)[source]#
Backwards pass to invert the transformation and uncertainty propagation
- extend(*args)[source]#
Extends the list of transforms with another list of transforms
- Parameters:
- *args
BaseTransform Transformations to extend MultiTransform transforms list
- *args
- extra_repr()[source]#
Additional representation of the transformation
- Returns:
strTransform specific representation
- class Normalise(*, mean=True, dim=None, offset=None, scale=None, data=None)[source]#
Bases:
BaseTypeTransformNormalises the data to zero mean and unit variance, or between 0 and 1.
- Overloads:
- class Normalise(self, *, offset: numpy.ndarray, scale: numpy.ndarray) None
- class Normalise(self, *, data: numpy.ndarray | torch.Tensor, mean: bool = ..., dim: int | tuple[int, ...] | None = ...) None
- Parameters:
- meanbool,
Optional If data should be normalised to zero mean and unit variance, or between 0 and 1, default = True
- dim
int|tuple[int, …] |NoneType,Optional Dimensions to normalise over, if None, all dimensions will be normalised over
- offset
ndarray|NoneType,Optional Offset to subtract from the data if data argument is None
- scale
ndarray|NoneType,Optional Scale to divide the data if data argument is None
- data
ArrayLike|NoneType,Optional Data to normalise with shape (N,…), where N is the number of elements
- meanbool,
- backward_grad(x, uncertainty)[source]#
Backwards pass to invert the transformation and uncertainty propagation
- extra_repr()[source]#
Additional representation of the transformation
- Returns:
strTransform specific representation
- class NumpyTensor(*, dtype=torch.float32)[source]#
Bases:
BaseTransformConverts Numpy arrays to PyTorch tensors.
- Attributes:
- dtype
torch.dtype Data type of the tensor
- dtype
- Parameters:
- dtype
dtype,Optional Data type of the tensor, default = torch.float32
- dtype
- backward_grad(x, uncertainty)[source]#
Backwards pass to invert the transformation and uncertainty propagation
- class Reshape(*, in_shape=None, out_shape=None)[source]#
Bases:
BaseTypeTransformReshapes the data.
- Parameters:
- backward_grad(x, uncertainty)[source]#
Backwards pass to invert the transformation and uncertainty propagation
- extra_repr()[source]#
Additional representation of the transformation
- Returns:
strTransform specific representation