LinearTransformation¶
- class torchaug.transforms.LinearTransformation(transformation_matrix, mean_vector)[source]¶
Transform a tensor image or video with a square transformation matrix and a mean_vector computed offline.
Given transformation_matrix and mean_vector, will flatten the torch.Tensor and subtract mean_vector from it which is then followed by computing the dot product with the transformation matrix and then reshaping the tensor to its original shape.
- Applications:
whitening transformation: Suppose X is a column vector zero-centered data. Then compute the data covariance matrix [D x D] or the batch covariance matrix [B x D x D] with torch.mm(X.t(), X), perform SVD on this matrix and pass it as transformation_matrix.
- Parameters:
transformation_matrix (
Tensor) – tensor [D x D] or [B x D X D], D = C x H x Wmean_vector (
Tensor) – tensor [D] or [B X D], D = C x H x Wbatch_inplace – whether to apply the batch transform in-place. Does not prevent functionals to make copy but can reduce time and memory consumption.
batch_transform – whether to apply the transform in batch mode.