Archive — one question answered
Why must data be vectorized?
You cannot feed raw email text into a net — how do you turn it into numbers?
A neural net only accepts fixed-length numbers, not variable-length raw text. In the course spam inbox, each email becomes three counts: promotional words, links, unknown sender. Email A is , email B is — same dimension .
Storing only the string "50% off today" leaves every message a different length, so there is no shared matrix multiply. Vectorization picks a feature dictionary and counts in a fixed order. Permuting columns changes meaning: is not .
Python on four tiny emails:
counts = [(2, 0, 1), (0, 1, 1), (5, 2, 1), (0, 0, 0)]
assert all(len(x) == 3 for x in counts)During batch training, NumPy stacks an matrix of shape (batch, 3) and multiplies once by . That is why deep learning courses start with vectorization: it is the prerequisite for GPUs and gradient descent at scale. The spam filter project in the course never sees raw email bodies in the training loop — only these fixed-length vectors.