torchcvnn.transforms.HWC2CHW¶
- class torchcvnn.transforms.HWC2CHW(dtype: str | None = None)[source]¶
Converts an input array/tensor from HWC to CHW format.
This transform reorders the dimensions of the input array/tensor from Height x Width x Channel to Channel x Height x Width format.
- Returns:
Input with dimensions reordered to Channel x Height x Width.
- Return type:
np.ndarray | torch.Tensor
Example
>>> transform = HWC2CHW() >>> x = torch.randn(3, 4, 5) # Shape (3, 4, 5) >>> y = transform(x) # Shape (5, 3, 4)
Methods
__init__([dtype])