mindspore.dataset.vision.py_transforms.LinearTransformation

class mindspore.dataset.vision.py_transforms.LinearTransformation(transformation_matrix, mean_vector)[source]

Apply linear transformation to the input NumPy image array, given a square transformation matrix and a mean vector.

The transformation first flattens the input array and subtracts the mean vector from it. It then computes the dot product with the transformation matrix, and reshapes it back to its original shape.

Parameters
  • transformation_matrix (numpy.ndarray) – a square transformation matrix of shape (D, D), where \(D = C \times H \times W\).

  • mean_vector (numpy.ndarray) – a NumPy ndarray of shape (D,) where \(D = C \times H \times W\).

Examples

>>> import mindspore.dataset.vision.py_transforms as py_vision
>>> from mindspore.dataset.transforms.py_transforms import Compose
>>>
>>> Compose([py_vision.Decode(),
>>>          py_vision.Resize(256),
>>>          py_vision.ToTensor(),
>>>          py_vision.LinearTransformation(transformation_matrix, mean_vector)])