Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

ELU and SELU Operator

Open zhouxiao-coder opened this issue 9 years ago • 2 comments

  • Doc: http://pytorch.org/docs/master/nn.html#torch.nn.SELU
    • Activation in Paddle: https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/operators/activation_op.h

zhouxiao-coder avatar Sep 25 '17 09:09 zhouxiao-coder

@qingqing01 I am working on these two activation operators, and I'm not sure if we need a separate SELU implementation in the core c++ code.

Here are the formulations of these 2 activations:

  • elu(x) = max(0,x) + min(0, alpha * (exp(x) - 1)). where alpha defaults to 1.
  • selu(x) = scale * elu(x), where alpha and scale are default to some "magic numbers" to keep outputs self-normalized.

So they differ by only a scale factor and different alpha value, I think it's probably better to wrap it later in some python code.

zhouxiao-coder avatar Sep 26 '17 04:09 zhouxiao-coder

I think it's probably better to wrap it later in some python code.

@zhouxiao-coder I agree with you.

From the formula selu(x) = scale * elu(x), the selu_op is a net_op with a elu_op and a scale_op. If implemented in C++ code, also can use two operators to compose.

qingqing01 avatar Sep 26 '17 05:09 qingqing01