Home Knowledge Base Gradient Clipping

Gradient Clipping — a technique that limits the magnitude of gradients during backpropagation to prevent exploding gradients from destabilizing training.

The Problem

Methods

``python torch.nn.utils.clip_grad_norm_(model.parameters(), max_norm=1.0) `` If $||g|| > max\_norm$: $g \leftarrow g \times \frac{max\_norm}{||g||}$ Preserves gradient direction, just limits magnitude

``python torch.nn.utils.clip_grad_value_(model.parameters(), clip_value=0.5) `` Simpler but can change gradient direction

Common Settings

When to Use

Gradient clipping is a simple safety mechanism that virtually every modern deep learning training pipeline includes.

gradient clippinggradient explosionclip grad norm

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.