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