composer.functional.resize_batch(input, target, scale_factor, mode='resize', resize_targets=False)[source]#

Resize inputs and optionally outputs by cropping or interpolating.

  • input (Tensor) โ€“ input tensor of shape (N, C, H, W). Resizing will be done along dimensions H and W using the constant factor scale_factor.

  • target (Tensor) โ€“ output tensor of shape (N, H, W) or (N, C, H, W) that will also be resized if resize_targets is True,

  • scale_factor (float) โ€“ scaling coefficient for the height and width of the input/output tensor. 1.0 keeps the original size.

  • mode (str, optional) โ€“ type of scaling to perform. Value must be one of 'crop' or 'resize'. 'crop' performs a random crop, whereas 'resize' performs a nearest neighbor interpolation. Default: "resize".

  • resize_targets (bool, optional) โ€“ whether to resize the targets, y. Default: False.

  • X_sized โ€“ resized input tensor of shape (N, C, H * scale_factor, W * scale_factor).

  • y_sized โ€“ if resized_targets is True, resized output tensor of shape (N, H * scale_factor, W * scale_factor) or (N, C, H * scale_factor, W * scale_factor). Depending on the input y. Otherwise returns original y.


from composer.algorithms.progressive_resizing import resize_batch
X_resized, y_resized = resize_batch(X_example,