Project DelphiTensors Workshop

shape, ndim and size

Every NumPy array carries three numbers worth knowing:

  • .shape — the size along each axis, as a tuple
  • .ndim — how many axes there are, the length of that tuple
  • .size — how many numbers the array holds in total

size is always the product of the entries in shape: for (2, 3, 4), 2 × 3 × 4 = 24.