#405SELU activationEasyNeural NetworksActivation Functions
SELU activation
Background
SELU (Scaled Exponential Linear Unit) is a self-normalizing activation: with the right weight init (LeCun normal) it drives layer activations toward zero mean and unit variance automatically, removing the need for batch norm in fully-connected nets. It is an ELU scaled by a fixed factor with precisely chosen constants.
Problem statement
Implement selu(x):
with the fixed constants and .
Input
x—np.ndarray: input (any shape).
Output
Returns an np.ndarray of the same shape.
Examples
Example 1
Input: x = [-1, 0, 1, 2]
Output: [-1.1113, 0.0, 1.0507, 2.1014]
Explanation: for , SELU (so , ); for , (so ); and .
Constraints
- Use the exact constants and .
- Positive branch: ; non-positive branch: .
- Elementwise; tests compare with
atol=1e-4.
Notes
- The constants are derived (Klambauer et al., 2017) so the activation is a fixed point of mean/variance propagation — the "self-normalizing" property.
- SELU pairs with LeCun-normal init and "alpha dropout"; outside that recipe its self-normalizing guarantee doesn't hold.
Python
Loading...
▶ Run executes the 3 visible sample tests below in your browser. Submit runs the full suite — including hidden tests — on the server for an official verdict.
- •Example: mixed small inputs
- •Example: positive branch is lambda times x
- •Reference: a random array matches the formula