wikillm

Paper · 2018-04-08 · cs.LG, stat.ML

Comparison of non-linear activation functions for deep neural networks on MNIST classification task

A single-author coursework comparison on MNIST. Sigmoid, ReLU, Leaky ReLU, ELU and SELU are trained as two-hidden-layer MLPs over learning rates 0.01 to 0.2. ELU is kept, then deeper ELU nets (2 to 8 hidden layers) are compared under four weight initialisers. Best validation accuracy is 0.983 (Glorot uniform, 7 layers; fan_in, 5 layers). Author-reported, single split.

Multi-layer perceptron (MLP)Activation functionWeight initializationactivation-functionsweight-initializationdeep-networksmnist

arXivPDFMarkdown10 min read

AI-compiled by claude-haiku-5-5 on 2026-11-08, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.

In plain words

A neural network is built from layers of simple units. Each unit adds up its inputs and passes the sum through a bend, the activation function. The classic bend is the sigmoid, which squashes everything into a fixed range. Newer bends (ReLU and its variants) are simpler and keep a useful signal flowing when a network has many layers.

This paper tests five such bends on a small handwritten-digit task (MNIST). It runs each one at several learning rates, then picks one bend and makes the network deeper, one layer at a time. It also tries several ways of choosing the starting weights, since the start matters more as the network gets deeper. The main lesson the card records is that the bends the author tested all beat the sigmoid on this task, and that deeper networks were a little more accurate up to a point, with the best starting-weight rule depending on the depth.

TL;DR

  • Five activation functions (sigmoid, ReLU, Leaky ReLU, ELU, SELU) are compared as 2-hidden-layer, 100-unit MLPs on MNIST at four learning rates §3.
  • Every ReLU-family function beats sigmoid on validation accuracy at the same learning rate tab. 4. ELU is chosen for the depth study §3.
  • With ELU, validation accuracy rises from 2 to about 5–7 hidden layers, then flattens; the best value is 0.983 tab. 6.
  • The paper is a single-student coursework report with one split, no test-set numbers and no code. Treat the differences between activations (about 0.2 to 0.5 points) as within noise until repeated.

Problem

Activation functions shape how gradients flow through deep networks. The paper notes that the sigmoid lets gradients vanish in deep stacks, that ReLU passes gradient 1 for positive inputs, and that ReLU units can "die" (stay at zero for every input) §2. It asks which of the ReLU variants and SELU helps on a standard classification task, and whether depth and the starting-weight rule change the result §1. It states no assumptions beyond the MNIST setup.

Method

The study is an empirical comparison, not a new method. It has three parts.

  1. Activation sweep §3. Five activations are trained as MLPs with two hidden layers of 100 units. The learning rate takes the values 0.01, 0.05, 0.1 and 0.2. Training and validation error and accuracy are recorded tab. 1–tab. 4. The text describes the sweep as four runs per activation, one per learning rate; whether these were single seeds is not stated.
  2. ELU vs SELU §3 fig. 3 fig. 4. ELU is kept over SELU because it gave better loss and accuracy in most of the author's runs. The SELU runs that were better sometimes, mostly at learning rate 0.05, are not reported.
  3. Depth and initialisation §4. ELU networks with 2 to 8 hidden layers are trained under four initialisers: a uniform rule ("Glorot uniform"), a variance scaled by fan_in, a variance scaled by fan_out, and a Gaussian Glorot rule tab. 5 tab. 6. A SELU run with 2 to 8 layers compares a uniform and a Gaussian initialiser tab. 7 fig. 6.

The activation functions, with the derivative the paper gives for each:

Pseudocode
# Activation functions used in the comparison  [§2] [eq. 1]-[eq. 8]
# Input:  x (scalar pre-activation)
# Output: activation value; the derivative is noted in each comment

def relu(x):
    # max(0, x); derivative is 0 for x <= 0 and 1 for x > 0  [eq. 1] [eq. 2]
    return max(0.0, x)

def leaky_relu(x, alpha=0.01):
    # alpha * x for x <= 0, x otherwise; alpha = 0.01  [eq. 3] [eq. 4]
    # derivative is alpha for x <= 0 and 1 for x > 0
    if x > 0:
        return x
    return alpha * x

def elu(x, alpha=1.0):
    # alpha * (exp(x) - 1) for x <= 0, x otherwise; alpha = 1  [eq. 5]
    # derivative is elu(x) + alpha for x <= 0 and 1 for x > 0  [eq. 6]
    if x > 0:
        return x
    return alpha * (exp(x) - 1.0)

def selu(x, alpha=1.6733, lam=1.0507):
    # lam times elu(x), with the constants as printed  [eq. 7] [eq. 8]
    # derivative is elu(x) + lam * alpha for x <= 0, and lam for x > 0
    return lam * elu(x, alpha)

The sigmoid baseline is not given a formula in the paper §2.

The starting-weight rules, as the paper describes them. The scale is only given for the SELU Gaussian case.

Pseudocode
# Weight initialisers compared  [§1] [§4]
# Input:  fan_in (incoming connections), fan_out (outgoing connections)
# Output: weight matrix of one layer

def init_fan_in(fan_in, fan_out):
    # Uniform rule whose variance depends on incoming connections only
    # Exact bounds are not stated  [§1]
    return uniform_bounds_not_stated(fan_in)

def init_fan_out(fan_in, fan_out):
    # Uniform rule whose gradient variance depends on outgoing
    # connections only; exact bounds not stated  [§1]
    return uniform_bounds_not_stated(fan_out)

def init_glorot_uniform(fan_in, fan_out):
    # Glorot and Bengio uniform rule; bounds not stated in this paper  [§4]
    return uniform_bounds_not_stated(fan_in, fan_out)

def init_selu_gaussian(fan_in):
    # Normal with mean 0 and variance 1 / n_i, n_i = incoming connections  [§4]
    return normal(mean=0.0, variance=1.0 / fan_in)

The training loop is not described beyond these settings:

Pseudocode
# Experimental protocol  [§1] [§3] [§4]
# Input:  activation, initialiser, depth, learning rate
# Output: validation error and accuracy after training

def run_configuration(activation, init, depth, learning_rate):
    # Sweep: depth 2, 100 units per layer, 100 epochs  [§3]
    # Depth study: depth 2 to 8, 50 epochs  [§1] [§4]
    # Batch size 50 in both parts  [§1]
    network = build_mlp(depth, activation, init)
    # Optimiser, loss and the learning-rate schedule are not stated
    train(network, learning_rate=learning_rate, batch_size=50)
    return validation_error(network), validation_accuracy(network)

Key equations. The paper's own equations are the eight in the activation section eq. 1–eq. 8; they are reproduced in the pseudocode above.

Hyperparameters

NameValueWhereNotes
hidden layers, activation sweep2§3
units per hidden layer, sweep100§3width for depth runs not stated
batch size50§1 §3 §4same in both parts
epochs, activation sweep100§1 §3
epochs, depth experiments50§1 §4halved; text says the 100-epoch runs stopped improving §4
learning rate grid0.01, 0.05, 0.1, 0.2§3 tab. 1–tab. 4
learning rate chosen0.1§3picked for accuracy; the LR of the ELU depth runs is not stated
learning rate, SELU depth runs0.05§4
Leaky ReLU alpha0.01§2 eq. 3
ELU alpha1§2 eq. 5
SELU alpha1.6733§2 eq. 7as printed, four digits
SELU lambda1.0507§2 eq. 7as printed, four digits
depth range2 to 8 hidden layers§4 tab. 5–tab. 7depth 1 not reported
data split50,000 train, 10,000 validation, 10,000 test§1test set never reported
optimisernot stated
loss functionnot statedtables report "error"
momentum, weight decay, dropoutnot stated
learning-rate schedulenot stated
number of runs or seedsnot stated§3text says "four times" per activation
Glorot uniform and fan boundsnot stated§1 §4

Results

Author-reported. Setup: MNIST, validation split, 2 hidden layers of 100 units for the activation sweep §3 and ELU or SELU 2–8 hidden-layer networks for the depth study §4. The baseline is the sigmoid network and, for depth, the 2-layer network with the same initialiser. Hardware and training time are not stated. Test-set accuracy is not reported.

SettingMetricBaselineThis paperSource
2×100 MLP, LR 0.1validation accuracysigmoid 0.979ReLU 0.980, ELU 0.980, SELU 0.978, LReLU 0.979tab. 4
2×100 MLP, LR 0.2validation accuracysigmoid 0.977LReLU 0.982, SELU 0.981, ELU 0.981tab. 4
ELU, 2 layers, Glorot uniformvalidation accuracysigmoid, LR 0.1 0.9790.980tab. 6
ELU, best depth, Glorot uniformvalidation accuracy2 layers 0.9800.983 at 7 layerstab. 6
ELU, best depth, fan_invalidation accuracy2 layers 0.9790.983 at 5 layerstab. 6
ELU, Glorot uniform, depth 2 vs 5validation error2 layers 0.1005 layers 0.108 (lowest error is at 2 layers)tab. 5

The full tables follow. Values are written as in the paper, with the printed e_-k read as e-k. Rows are learning rates (activation sweep) or depths.

Training error by learning rate (activation sweep) tab. 1:

LRSigmoidReLULReLUELUSELU
0.011.64e-19.56e-31.11e-22.13e-21.45e-2
0.052.61e-24.03e-44.15e-45.91e-45.97e-4
0.15.57e-31.42e-41.44e-42.05e-42.07e-4
0.21.33e-35.12e-55.68e-57.78e-56.09e-5

Validation error by learning rate tab. 2:

LRSigmoidReLULReLUELUSELU
0.011.65e-19.14e-29.64e-28.40e-29.64e-2
0.058.57e-21.11e-11.22e-11.21e-11.14e-1
0.18.33e-21.17e-11.20e-11.15e-11.25e-1
0.29.83e-21.25e-11.15e-11.20e-11.22e-1

Training accuracy by learning rate tab. 3:

LRSigmoidReLULReLUELUSELU
0.010.9530.9990.9990.9960.998
0.050.9951.0001.0001.0001.000
0.11.0001.0001.0001.0001.000
0.21.0001.0001.0001.0001.000

Validation accuracy by learning rate tab. 4:

LRSigmoidReLULReLUELUSELU
0.010.9550.9770.9760.9780.974
0.050.9740.9790.9770.9780.976
0.10.9790.9800.9790.9800.978
0.20.9770.9790.9820.9810.981

Validation error for ELU by depth and initialiser tab. 5:

LayersGlorot uniformfan_infan_outGaussian
21.00e-11.07e-11.24e-11.17e-1
31.09e-11.17e-11.30e-11.21e-1
41.26e-11.27e-11.19e-11.26e-1
51.08e-11.10e-11.25e-11.17e-1
61.23e-11.19e-11.45e-11.13e-1
71.16e-11.35e-11.30e-11.14e-1
81.23e-11.22e-11.33e-11.19e-1

Validation accuracy for ELU by depth and initialiser tab. 6:

LayersGlorot uniformfan_infan_outGaussian
20.9800.9790.9780.978
30.9810.9800.9790.980
40.9800.9810.9810.981
50.9820.9830.9820.982
60.9820.9820.9810.981
70.9830.9820.9830.983
80.9820.9820.9820.982

SELU, Glorot uniform vs Gaussian (LR 0.05) tab. 7:

LayersUniform errorGaussian errorUniform accuracyGaussian accuracy
21.01e-11.04e-10.9770.976
31.11e-11.08e-10.9790.979
41.16e-11.17e-10.9780.980
51.19e-11.18e-10.9800.980
61.21e-11.18e-10.9810.980
71.20e-11.16e-10.9810.982
81.21e-11.12e-10.9810.981

Figures are described, not reproduced: fig. 1 and fig. 2 show ELU error and accuracy against learning rate; fig. 3 and fig. 4 compare ELU and SELU over training; fig. 5 shows the four ELU initialisers at 5 layers; fig. 6 shows the SELU comparison at 7 layers. The text reads these figures for overfitting onset, which it places around epoch 20 §3.

Paper vs code

No official code. No link to a code repository appears in the paper, its arXiv metadata or the LaTeX source. The GitHub repository search for the title returned nothing, and a search for the author's surname returned nothing. The source tree contains only the LaTeX sources and figure PDFs.

Pitfalls

  • Learning-rate trend contradicts the table. The text says the loss rises with the learning rate §3. Training error tab. 1 falls as the rate rises, by two or more orders of magnitude for every activation. Only validation error tab. 2 rises for most columns.
  • Accuracy gain from LR 0.05 to 0.1 is overstated. The text says validation accuracy rises by 2–4% §3. Table 4 shows rises of 0.1 to 0.5 percentage points. The card uses the table.
  • ELU vs SELU "2% better". The text says ELU is about 2% better in accuracy §3 fig. 3. No table gives this comparison, and the activation-sweep numbers in tab. 4 differ by under one point. The figures' learning rate and epoch count are not stated.
  • Selection on the validation set. The choice of ELU and of learning rate, and the early-stopping point, are made on the validation split. The test set is never reported, so these numbers are optimistic.
  • Selective reporting. The text says SELU sometimes beat ELU, but those runs are "not reported" §3. The ELU choice rests on runs the author chose to show.
  • Gaussian vs uniform (SELU). The text says the Gaussian gives better accuracy §4. Table 7 shows the sign of the accuracy difference changes across depths, with gaps of 0.2 points or less. Error is lower for Gaussian at most depths, but the gap is small.
  • Single values, no spread. The tables give one value per cell and no standard deviation or seed count. The text says results varied between runs but does not quantify it §3, so differences of 0.001 to 0.002 accuracy cannot be judged from the card.
  • Initialiser formulas are missing. The fan_in and fan_out rules, and the Glorot uniform bounds, are named but not written out §1 §4. Implement them from the cited originals, and say which variant you used.
  • Width and optimiser for depth runs. The depth-experiment width, optimiser, loss and learning-rate schedule are not stated. An implementer has to choose them, and the depth curve may depend on that choice.
  • Abstract vs body. The abstract promises an analysis of how the number of incoming and outgoing connections affects the network [abstract]. The body compares four initialisers at fixed depth and gives no connection-count analysis beyond that.
  • Typesetting. Numbers in the source are printed as e_-1 (the underscore stands for a minus sign). Table 4 is cited as "table 4" in the text and as "Table 4" elsewhere; both mean the same table.
  • Equation numbers. Equations are numbered in source order eq. 1–eq. 8 because the article class numbers displayed equations. This has not been checked against the compiled PDF.

Lineage

  • Builds on: ReLU, Leaky ReLU, ELU, SELU and Glorot initialisation, all cited in §1 and §2 without arXiv ids in the source.
  • Compared against: sigmoid (baseline) tab. 1–tab. 4; ReLU and Leaky ReLU within the same sweep; Glorot uniform and fan-based initialisers in the depth study tab. 5–tab. 7.
  • Superseded by: not stated.

Source and license

Adapted from “Comparison of non-linear activation functions for deep neural networks on MNIST classification task” by Dabal Pedamonti (arXiv:1804.02763), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors.