composer.algorithms.functional.resize_inputs
- composer.algorithms.functional.resize_inputs(X, y, scale_factor, mode='resize', resize_targets=False)[source]
Resize inputs and optionally outputs by cropping or interpolating.
- Parameters
X (torch.Tensor) – Input tensor of shape (N, C, H, W). Resizing will be done along dimensions H and W using the constant factor scale_factor.
y (torch.Tensor) – If resize_targets is True, output tensor of shape (N, C, H, W) that will also be resized.
scale_factor (float) – Scaling coefficient for the height and width of the input/output tensor. 1.0 keeps the original size.
mode (str) – Type of scaling to perform. Value must be one of ‘crop’ or ‘resize’. ‘crop’ performs a random crop, whereas ‘resize’ performs a bilinear interpolation. Default: ‘crop’.
resize_targets (bool) – Resize the targets, y, as well. Default: False.
- Returns
X_sized (torch.Tensor) – Resized input tensor of shape (N, C, H * scale_factor, W * scale_factor).
y_sized (torch.Tensor) – If resized_targets is True, resized output tensor of shape (N, C, H * scale_factor, W * scale_factor). Returns original y, otherwise.
- Return type
Tuple[torch.Tensor, torch.Tensor]