Table of Contents
Shortcuts

# UpsamplingBilinear2d

class torch.nn.UpsamplingBilinear2d(size=None, scale_factor=None)

  Applies a 2D bilinear upsampling to an input signal composed of several input channels.

  To specify the scale, it takes either the `size` or the `scale_factor` as it’s constructor argument.

  When `size` is given, it is the output size of the image (h, w).

  Parameters:

    - size (int or Tuple[int, int], optional) – output spatial sizes

    - scale_factor (float or Tuple[float, float], optional) – multiplier for spatial size.

  Warning

  This class is deprecated in favor of `interpolate()`. It is equivalent to `nn.functional.interpolate(..., mode='bilinear', align_corners=True)`.

  Shape:

    - Input: (N,C,H i n,W i n)(N, C, H_{in}, W_{in})(N,C,H in​,W in​)

    - Output: (N,C,H o u t,W o u t)(N, C, H_{out}, W_{out})(N,C,H o u t​,W o u t​) where

  H o u t=⌊H i n×scale_factor⌋H_{out} = \left\lfloor H_{in} \times \text{scale\_factor} \right\rfloor H o u t​=⌊H in​×scale_factor⌋
  W o u t=⌊W i n×scale_factor⌋W_{out} = \left\lfloor W_{in} \times \text{scale\_factor} \right\rfloor W o u t​=⌊W in​×scale_factor⌋

  Examples:

      >>> input = torch.arange(1, 5, dtype=torch.float32).view(1, 1, 2, 2)
      >>> input
      tensor([[[[1., 2.],
                [3., 4.]]]])

      >>> m = nn.UpsamplingBilinear2d(scale_factor=2)
      >>> m(input)
      tensor([[[[1.0000, 1.3333, 1.6667, 2.0000],
                [1.6667, 2.0000, 2.3333, 2.6667],
                [2.3333, 2.6667, 3.0000, 3.3333],
                [3.0000, 3.3333, 3.6667, 4.0000]]]])

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.