SELU activationEasynumpyactivationneural-netself-normalizingselu
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...
This problem ships 4 hidden tests. They run in your browser via Pyodide — no backend, no submission queue. Press ▶ Run tests to execute.
- •Reference values
- •Positive branch is lambda * x
- •selu(0) = 0
- •Negative branch saturates near -lambda*alpha