The first object you must understand
Every input to a neural network, every model weight, every gradient, every activation — all of them are tensors. Before any architecture talk, internalize what a tensor is and is not.
A tensor is a generalization of scalars, vectors, and matrices to arbitrary numbers of dimensions. The number of dimensions is the rank (also called order or ndim):
- Rank 0 — a scalar. Shape
(). Example:4.5. - Rank 1 — a vector. Shape
(n,). Example:[1.0, 2.0, 3.0]. - Rank 2 — a matrix. Shape
(rows, cols). Example: a 28×28 grayscale image, shape(28, 28). - Rank 3 — Example: an RGB image, shape
(height, width, 3). - Rank 4 — Common in deep learning: a batch of images, shape
(batch, height, width, channels).
Every tensor has three core properties: shape (dimensions), dtype (data type), and values. The dtype determines storage precision — float32 for neural-network weights, int32/int64 for labels and indices, bool for masks.
Why this matters: Shape mismatches cause the majority of runtime errors in TF code. Once you can read shapes fluently — at every stage of a pipeline, after every layer — debugging becomes radically faster.