The four layers you'll reach for first
A Sequential model is only as expressive as the layers you stack into it, and for the bulk of everyday work four core layers carry the load:
Dense(units, activation)— fully connected layer, the workhorse. Every input connects to every output;unitsis how many outputs it produces.Dropout(rate)— randomly zeroes a fraction of its inputs during training only to fight overfitting. At inference it's a no-op, so you never remove it for prediction.Flatten()— collapses a multi-dimensional input into 1D (a 28×28 image becomes a 784-vector) so aDenselayer, which only speaks in vectors, can consume it.Activation(fn)— applies a nonlinearity. You'll rarely use it standalone; the idiom is to fold it into the layer withDense(64, activation="relu").
The first layer is special: it needs a shape
Every layer after the first infers its input shape from the layer before it — but the first layer has nothing to infer from, so you have to tell it. The clean way is to make keras.Input(shape=(...)) the first element of the stack. Until Keras knows that shape it can't allocate weights, which is why a model with no declared input stays "unbuilt" and summary() complains. Declaring it up front means your model is fully built the instant it's constructed, before a single batch of data shows up (the Code section shows the full stack).