Learn Before
Concept

Tensor Element Summation

Often, it is necessary to calculate the total sum of a tensor's elements mathematically. For a vector x\mathbf{x} of length nn, the sum of its elements is expressed as i=1nxi\sum_{i=1}^n x_i. To express sums over tensors of arbitrary shape, the summation simply extends over all of its axes. For example, the sum of all elements in an m×nm \times n matrix A\mathbf{A} is written using multiple summations as i=1mj=1naij\sum_{i=1}^{m} \sum_{j=1}^{n} a_{ij}. Programmatically, summing all the elements within a tensor yields a new tensor containing only a single element.

0

1

Updated 2026-05-02

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L

Related