Concept

Accessing Tensor Shape Attribute

Beyond using the len() function, a tensor's length along each of its axes can be accessed via the shape attribute. The shape attribute returns a tuple indicating these lengths. For instance, a one-dimensional tensor (a vector) returns a tuple containing just a single element representing its total length.

0

1

Updated 2026-05-01

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L