Bilinear

class paddle.nn.initializer. Bilinear [源代码]

该接口为参数初始化函数,用于转置卷积函数中,对输入进行上采样。用户通过任意整型因子放大 shape 为(B,C,H,W)的特征图。

返回

该参数初始化的类实例对象

代码示例

>>> import math

>>> import paddle
>>> import paddle.nn as nn
>>> from paddle.regularizer import L2Decay

>>> factor = 2
>>> C = 2
>>> B = 8
>>> H = W = 32
>>> w_attr = paddle.ParamAttr(learning_rate=0.,
...                           regularizer=L2Decay(0.),
...                           initializer=nn.initializer.Bilinear())
>>> data = paddle.rand([B, 3, H, W], dtype='float32')
>>> conv_up = nn.Conv2DTranspose(3,
...                              out_channels=C,
...                              kernel_size=2 * factor - factor % 2,
...                              padding=int(
...                                  math.ceil((factor - 1) / 2.)),
...                              stride=factor,
...                              weight_attr=w_attr,
...                              bias_attr=False)
>>> x = conv_up(data)