FusedDropoutAdd¶
实现了 Dropout 和 Add 的融合
参数¶
p (float|int, 可选): 将单位设置为零的概率。默认值: 0.5
mode (str, 可选): ['upscale_in_train'(默认) | 'downscale_in_infer']
upscale_in_train (默认), 在训练时放大输出
train: \(out = x \times \frac{mask}{(1.0 - p)} + y\)
inference: \(out = x + y\)
downscale_in_infer, 在推理时缩小输出
train: \(out = x \times mask + y\)
inference: \(out = x \times (1.0 - p) + y\)
name (str, 可选): 操作的名称, 默认值为 None. 有关更多信息请参阅 Name.
形状¶
x: N-D 张量.
y: N-D 张量.
output: N-D 张量, 和 x 形状相同.
代码示例¶
>>> import paddle
>>> paddle.device.set_device('gpu')
>>> from paddle.incubate.nn.layer.fused_dropout_add import FusedDropoutAdd
>>> x = paddle.to_tensor([[1,2,3], [4,5,6]], dtype="float32")
>>> y = paddle.to_tensor([[1,2,3], [4,5,6]], dtype="float32")
>>> m = FusedDropoutAdd(p=0.5)
>>> out = m(x, y)