class paddle.nn. AlphaDropout ( p=0.5, name=None ) [source]

Alpha Dropout is a type of Dropout that maintains the self-normalizing property. For an input with zero mean and unit standard deviation, the output of Alpha Dropout maintains the original mean and standard deviation of the input. Alpha Dropout fits well to SELU activate function by randomly setting activations to the negative saturation value.

For more information, please refer to: Self-Normalizing Neural Networks

In dygraph mode, please use eval() to switch to evaluation mode, where dropout is disabled.

  • p (float | int) – Probability of setting units to zero. Default: 0.5

  • name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.

  • input: N-D tensor.

  • output: N-D tensor, the same shape as input.


import paddle
import numpy as np

x = np.array([[-1, 1], [-1, 1]]).astype('float32')
x = paddle.to_tensor(x)
m = paddle.nn.AlphaDropout(p=0.5)
y_train = m(x)
m.eval()  # switch the model to test phase
y_test = m(x)
# [[-0.10721093, 1.6655989 ], [-0.7791938, -0.7791938]] (randomly)
forward ( input )

Defines the computation performed at every call. Should be overridden by all subclasses.

  • *inputs (tuple) – unpacked tuple arguments

  • **kwargs (dict) – unpacked dict arguments

extra_repr ( )

Extra representation of this layer, you can have custom implementation of your own layer.