The five that actually bite
Sequential is forgiving until it isn't. These five mistakes account for the overwhelming majority of "my model won't train / trains but predicts garbage" reports — and the tell is that most of them fail loudly at the wrong layer rather than where the real mistake lives, which is what makes them so time-consuming to track down.
- Forgetting input shape — without
keras.Input(shape=...)the model stays unbuilt until it sees data, sosummary()errors and any shape bug surfaces late. Declare it explicitly. - Wrong output activation —
sigmoidon a 10-class head instead ofsoftmax. Sigmoid gives ten independent probabilities that don't sum to 1; softmax gives a proper distribution over the classes. - Mismatched loss function —
sparse_categorical_crossentropywants integer labels (0, 1, 2…),categorical_crossentropywants one-hot ([0,0,1,0…]). The error message points at shapes, not at the loss, so it reads as confusing. - Not normalizing input — raw 0–255 pixels make the loss landscape steep and training unstable. Always scale to [0, 1] or standardize to zero mean / unit variance.
- Too many or too few layers — start small. A 2–3 layer Dense net covers most tabular and simple image tasks; reach for depth only when validation accuracy plateaus, not preemptively.
The common thread: none of these are exotic. They're the boring, repeatable mistakes everyone makes, which is exactly why a fixed pre-flight habit beats debugging each one fresh.