(self, tensor: Tensor)
return tensor
Args:
            tensor (Tensor): Tensor image to be whitened.

        Returns:
            Tensor: Transformed image.
Args:
            tensor (Tensor): Tensor image to be whitened.
Args : tensor ( Tensor ) : Tensor image to be whitened .
def forward(self, tensor: Tensor) -> Tensor:
        """
        Args:
            tensor (Tensor): Tensor image to be whitened.

        Returns:
            Tensor: Transformed image.
        """
        shape = tensor.shape
        n = shape[-3] * shape[-2] * shape[-1]
        if n != self.transformation_matrix.shape[0]:
            raise ValueError(
                "Input tensor and transformation matrix have incompatible shape."
                + "[{} x {} x {}] != ".format(shape[-3], shape[-2], shape[
                    -1]) + "{}".format(self.transformation_matrix.shape[0]))

        if tensor.device.type != self.mean_vector.device.type:
            raise ValueError(
                "Input tensor should be on the same device as transformation matrix and mean vector. "
                "Got {} vs {}".format(tensor.device, self.mean_vector.device))

        flat_tensor = tensor.view(-1, n) - self.mean_vector
        transformed_tensor = torch.mm(flat_tensor, self.transformation_matrix)
        tensor = transformed_tensor.view(shape)
        return tensor
def forward ( self , tensor : Tensor ) -> Tensor : shape = tensor . shape n = shape [ - 3 ] * shape [ - 2 ] * shape [ - 1 ] if n != self . transformation_matrix . shape [ 0 ] : raise ValueError ( "Input tensor and transformation matrix have incompatible shape." + "[{} x {} x {}] != " . format ( shape [ - 3 ] , shape [ - 2 ] , shape [ - 1 ] ) + "{}" . format ( self . transformation_matrix . shape [ 0 ] ) ) if tensor . device . type != self . mean_vector . device . type : raise ValueError ( "Input tensor should be on the same device as transformation matrix and mean vector. " "Got {} vs {}" . format ( tensor . device , self . mean_vector . device ) ) flat_tensor = tensor . view ( - 1 , n ) - self . mean_vector transformed_tensor = torch . mm ( flat_tensor , self . transformation_matrix ) tensor = transformed_tensor . view ( shape ) return tensor