C.W.K.
Stream
Lesson 06 of 07 · published

Common Mistakes

~8 min · sequential

Level 0Keras Apprentice
0 XP0/97 lessons0/20 achievements
0/120 XP to next level120 XP to go0% complete

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, so summary() errors and any shape bug surfaces late. Declare it explicitly.
  • Wrong output activationsigmoid on a 10-class head instead of softmax. Sigmoid gives ten independent probabilities that don't sum to 1; softmax gives a proper distribution over the classes.
  • Mismatched loss functionsparse_categorical_crossentropy wants integer labels (0, 1, 2…), categorical_crossentropy wants 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.

External links

Exercise

Take a working MNIST script. Introduce each of the four mistakes above (one at a time). Note the error message in each case. Build a debug-mistakes.md cheatsheet for yourself.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.