Skip to main content
Luxara Academy

Archive — one question answered

How many numbers in an 8×8 digit image?

From an 8×8 grid to network input — how many dimensions?

A handwritten digit in the course digits set is an 8×8 grid; each cell is an integer 0–16 (ink strength). Flattening in a fixed row or column order gives x∈R64\mathbf{x} \in \mathbb{R}^{64} because 8×8=648 \times 8 = 64. That is the same vectorization idea as counting spam keywords, only the feature list is longer.

Example: if the top-left corner reads [0, 2, 4, 1, ...] across 64 cells, the net must always read the same order — permuting pixels changes meaning. Row-major order is the convention in the course code.

python
import numpy as np
grid = np.arange(64).reshape(8, 8)
vec = grid.ravel()
assert vec.shape == (64,)

scikit-learn’s load_digits has 1797 such images; the course ships a trimmed .npz so checks run offline without installing scikit-learn on every machine. This article bridges spam vectorization and digit recognition — the same flattening trick, only the dimension dd changes from 3 to 64.