﻿# GELU: a smooth activation that weights rather than clips values

GELU applies a smooth value-dependent weighting in neural feed-forward layers. Learn its shape, negative-input behavior and why exact and approximate forms differ.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/gelu-smooth-neural-activation/
Language: en

A linear projection alone cannot supply the nonlinear transformations used by a neural feed-forward block. GELU introduces a smooth activation between learned projections. Its shape is easier to understand by comparing what happens to positive, negative and near-zero inputs rather than by treating every activation as an on-off switch.

## A smooth weighting acts on the input value

The original GELU formulation multiplies a value by the standard normal cumulative distribution evaluated at that value. This gives a smooth value-dependent weighting rather than the hard positive-side rule familiar from ReLU. The expression is deterministic when its input is fixed. A probability distribution appears in its mathematical definition, but the layer need not draw a random sample for each coordinate. This separates GELU’s analytic weighting from stochastic operations that deliberately change the computation between repeated forward passes.

## Negative values are attenuated rather than all removed

For negative inputs, the weighting can produce a small negative output instead of replacing every value with zero. Around the origin, the transition is smooth. Large positive inputs receive a different relative treatment from strongly negative inputs. These shape properties explain why describing GELU as simply retaining positive features loses information. They do not assign semantic correctness to the sign of a hidden coordinate. Learned projections determine the representations on which the activation acts, and subsequent layers can combine them in different ways.

## The surrounding projections make the activation useful

A Transformer feed-forward block projects features, applies its chosen nonlinearity and projects again. The activation changes the family of functions the composition can represent compared with one purely linear transformation. A proposed tiny example fixes the projections and varies the input through negative and positive values, observing the intermediate activation before the final mixture. This isolates the nonlinear response. It is a teaching fixture rather than evidence that GELU will improve a particular task after arbitrary replacement of another trained activation.

## Preserve the defined numerical variant when porting

Implementations can offer approximations to the GELU function. An approximation may be appropriate for execution while still differing from another documented variant. The checkpoint’s architecture and reference code establish what is expected. Compare representative values and, where training matters, derivatives under a declared tolerance and precision. A familiar activation name is not sufficient to certify every fused implementation. The practical result is a precise local function that can be checked independently, then incorporated into the complete model’s acceptance rather than inferred from the block’s broad label.

## Primary research and implementation references

- [Attention Is All You Need](https://arxiv.org/abs/1706.03762).

- [Gaussian Error Linear Units](https://arxiv.org/abs/1606.08415).

- [GLU Variants Improve Transformer](https://arxiv.org/abs/2002.05202).

## Related engineering context

[Reproducible inference stacks: preserving a GPU pilot’s result](/journal/software-stack-reproducibility/); [A GPU inference benchmark you can trust](/journal/inference-benchmark-method/).
