liveBook · Manning

GELU

GELU, or Gaussian error linear unit, is a smooth neural-network activation function that scales an input by the cumulative distribution function of the standard normal distribution at that input.

How 2 Manning books explain it

Learn Generative AI with PyTorch

A smooth activation function used in neural networks to transform layer outputs and improve model performance.

How it is used
Uses a smooth nonlinear transformation inside Transformer feed-forward sublayers for language and music generation.
How deep it goes
Defines GELU, contrasts its differentiability with ReLU, and provides PyTorch code and a comparison plot without deriving the function.
Examples
Implements GELU in PyTorch, plots it against ReLU, and applies it in GPT-style text and music Transformers.
What you can do after
Builds a GELU module in PyTorch and places it within Transformer decoder feed-forward networks.

Read how Learn Generative AI with PyTorch explains GELU →

Build a Large Language Model (From Scratch)

A smooth activation function defined as x times the Gaussian CDF, used here in transformer feed-forward submodules.

How it is used
Activates hidden representations inside GPT-style transformer feed-forward networks.
How deep it goes
Defines the Gaussian-CDF form, implements a tanh approximation, compares ReLU behavior, and traces feed-forward tensor shapes.
Examples
Uses PyTorch code, GELU-versus-ReLU plots, and a [2, 3, 768] feed-forward shape example.
What you can do after
Build it from scratch as a PyTorch module and place it correctly in a GPT-style feed-forward network.

Read how Build a Large Language Model (From Scratch) explains GELU →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.