liveBook · Manning

Array

As explained in Inside Deep Learning: Math, Algorithms, Models

An array with any number of dimensions, including scalars, vectors, matrices, and higher-rank arrays.

An array is an n-dimensional data structure: a scalar has zero dimensions, a vector one, a matrix two, and higher-rank arrays more. In deep learning, arrays organize inputs, outputs, and network parameters. section 1.2

Write an array’s shape as an ordered tuple such as (B, C, W, H), or mathematically as ℝB,C,W,H. Dimension letters commonly describe batches, channels, widths, heights, or hidden outputs. section 1.2

Representing shapes in PyTorch

torch.tensor(3.14) has shape torch.Size([]); [1, 2, 3, 4] has shape torch.Size([4]); a four-by-two matrix has shape torch.Size([4, 2]); and a three-dimensional array can have shape torch.Size([4, 2, 3]). Arrays can also be converted from NumPy and sliced into row or column subvectors. section 1.2

Figure 1.4 Examples of tensors, with more dimensions or axes as we move from left to right. A scalar represents a single value. A vector is a list of values and is how we often think about one datapoint. A matrix is a grid of values and is often used for a dataset. A three-dimensional tensor can be used to represent a dataset of sequences.

Compare scalar, vector, matrix, and three-dimensional array shapes as dimensions increase. section 1.2

How Inside Deep Learning: Math, Algorithms, Models covers it

How deep it goes
Defines ranks, shapes, notation, slicing, and basic PyTorch operations without descending into array internals.
Examples
Uses scalars, vectors, matrices, three-dimensional arrays, NumPy conversion, slicing, summation, transposition, and boolean comparisons.
What it assumes
Assumes Python and prior NumPy experience while teaching scalar-to-higher-rank terminology and PyTorch equivalents.
What you can do after
Apply it via PyTorch by creating arrays, reading shapes, converting NumPy values, slicing, and performing basic operations.
How it connects
Connects arrays to tensors, NumPy, PyTorch, GPU computation, and automatic differentiation.

Also explained in

Compare how 40 books explain array →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Inside Deep Learning: Math, Algorithms, Models. The section links point to the parts of the book it draws on.