AIExplainer
Programming Frameworks Intermediate 1 min read

What is a shape?

The number of elements in each dimension of a tensor.

The number of elements in each dimension of a tensor. The shape is represented as a list of integers. For example, the following two-dimensional tensor has a shape of [3,4]:

TensorFlow uses row-major (C-style) format to represent the order of dimensions, which is why the shape in TensorFlow is`[3,4]` rather than`[4,3]`. In other words, in a two-dimensional TensorFlow Tensor, the shape is`[` number of rows, number of columns`]`. A static shape is a tensor shape that is known at compile time. A dynamic shape is unknown at compile time and is therefore dependent on runtime data. This tensor might be represented with a placeholder dimension in TensorFlow, as in`[3, ?]`.

Practitioners refer to shape when building, training, or evaluating machine learning systems. It appears in research papers, product documentation, and technical discussions about AI capabilities and limitations.