Learn Before
Code
Programmatic Tensor Reduction along an Axis
Deep learning libraries allow developers to specify the exact axes along which a tensor should be reduced when invoking summation functions. The dimension corresponding to the specified reduction axis is subsequently removed from the shape of the resulting output tensor. In PyTorch, MXNet, and JAX, this is achieved by providing the axis parameter (e.g., A.sum(axis=0) or A.sum(axis=[0, 1])), while TensorFlow utilizes the same parameter within its tf.reduce_sum(A, axis=0) function.
0
1
Updated 2026-05-02
Tags
D2L
Dive into Deep Learning @ D2L