Skip to content
Deep Learning

What are the problems with sigmoid as an activation function?

It saturates: for large positive or negative inputs its gradient is nearly zero, which causes vanishing gradients in deep networks. Its outputs are also always positive rather than zero-centered. Tanh fixes the centering but still saturates, which is why ReLU took over.

Proposed by @Al_Grigor

datasciencetrivia.com

Card 1 of 263. Answer: It saturates: for large positive or negative inputs its gradient is nearly zero, which causes vanishing gradients in deep networks. Its outputs are also always positive rather than zero-centered. Tanh fixes the centering but still saturates, which is why ReLU took over.

Created by santiviquez

About · Quizzes · History of AI · To suggest new questions or report an error send me a dm.

The longer answer

Sigmoid has three problems as a hidden-layer activation: it saturates, causing vanishing gradients; its output is not zero-centered; and it is relatively expensive to compute.

Saturation is the big one. For large positive or negative inputs the curve is flat, so its derivative is close to zero, and even at its peak the derivative is only 0.25. Backpropagation multiplies these derivatives layer after layer, so in a deep network the gradient reaching the early layers shrinks toward zero and those layers barely learn.

Because sigmoid outputs are always positive, the gradients for a neuron's weights all share the same sign, which pushes updates into an inefficient zig-zag. That is why ReLU and its variants replaced sigmoid in hidden layers, and tanh is preferred when a bounded output is needed. Sigmoid is still the right choice in the output layer for binary classification and inside the gates of LSTMs and GRUs.

Tanh, tanh(x) = (eˣ − e⁻ˣ) / (eˣ + e⁻ˣ), squashes inputs into (−1, 1) instead of (0, 1). It is a rescaled sigmoid, tanh(x) = 2σ(2x) − 1, so its outputs are zero-centered, and its derivative, 1 − tanh²(x), peaks at 1, four times sigmoid's 0.25. That is why tanh trained better than sigmoid in hidden layers before ReLU. It still saturates: the derivative is about 0.07 at x = 2 and 0.0099 at x = 3. Tanh lives on inside LSTMs and GRUs, which squash candidate states to (−1, 1), and in the output layer of image generators such as DCGAN.

All questions