Chapter 1

Tensors, Batches, and Shapes

Arrays, axes, batch dimensions, feature dimensions, and the shape habits used by neural networks.

What this chapter does

Before a network can learn, data must have shape. This chapter teaches how to read tensors as organized numbers, distinguish batches from features, and predict basic layer output shapes.

Lessons

Read these in order.

Start with the chapter introduction, then move through the topic lessons. The order is chosen so each page can reuse ideas from the pages before it.

  1. 01
    Introduction

    Why shape reasoning belongs at the beginning of Deep Learning.

  2. 02
    Scalars, Vectors, Matrices, and Tensors

    Arrays as organized numbers, with shape as part of the meaning.

  3. 03
    Batch and Feature Dimensions

    How examples and features appear in the shapes used by neural layers.

  4. 04
    Shape Notation and Axis Conventions

    How to read tensor shapes by naming each axis before trusting the numbers.

  5. 05
    Reshaping and Flattening

    Changing array shape while preserving the number of entries.

  6. 06
    Broadcasting

    Reusing smaller arrays across compatible axes, especially for bias terms.

  7. 07
    Parameters, Activations, and Outputs as Tensors

    The tensor roles that appear inside a neural network computation.

  8. 08
    Shape Debugging

    Tracing expected and actual shapes to find the first mismatch.

Before moving on

  • Read scalar, vector, matrix, and tensor shapes.
  • Distinguish batch dimensions from feature dimensions.
  • Predict the output shape of a basic linear layer.
  • Catch simple shape mismatches before reaching for a framework error.

Where this leads

  • Models as Functions
  • Linear Models and Scores
  • Activation functions
  • Loss functions

Chapter progress