Learn Before
Code

Programmatic L2 Norm Calculation

The 2\ell_2 norm of a vector can be calculated programmatically using linear algebra utilities in modern deep learning frameworks. In PyTorch and TensorFlow, this is accomplished by passing the vector to torch.norm(u) and tf.norm(u), respectively. In JAX and NumPy (used by MXNet), it is computed using the linear algebra module via jnp.linalg.norm(u) and np.linalg.norm(u).

0

1

Updated 2026-05-02

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L