# oneflow.nn.UpsamplingBilinear2d¶

class oneflow.nn.UpsamplingBilinear2d(size: Optional[Tuple[int, int]] = None, scale_factor: Optional[Tuple[float, float]] = 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_{in}, W_{in})$$

• Output: $$(N, C, H_{out}, W_{out})$$ where

$H_{out} = \left\lfloor H_{in} \times \text{scale_factor} \right\rfloor$
$W_{out} = \left\lfloor W_{in} \times \text{scale_factor} \right\rfloor$

For example:

>>> import numpy as np
>>> import oneflow as flow

>>> input = flow.tensor(np.arange(1, 5).reshape((1, 1, 2, 2)), dtype=flow.float32)
>>> input = input.to("cuda")
>>> m = flow.nn.UpsamplingBilinear2d(scale_factor=2.0)
>>> output = m(input)
>>> output
tensor([[[[1.0000, 1.3333, 1.6667, 2.0000],
...
[3.0000, 3.3333, 3.6667, 4.0000]]]], device='cuda:0',
dtype=oneflow.float32)

__init__(size: Optional[Tuple[int, int]] = None, scale_factor: Optional[Tuple[float, float]] = None)None

Initialize self. See help(type(self)) for accurate signature.

Methods

 __call__(*args, **kwargs) Call self as a function. __delattr__(name, /) Implement delattr(self, name). __dir__() Default dir() implementation. __eq__(value, /) Return self==value. __format__(format_spec, /) Default object formatter. __ge__(value, /) Return self>=value. __getattr__(name) __getattribute__(name, /) Return getattr(self, name). __gt__(value, /) Return self>value. __hash__() Return hash(self). __init__([size, scale_factor]) Initialize self. __init_subclass__ This method is called when a class is subclassed. __le__(value, /) Return self<=value. __lt__(value, /) Return self