Keras provides two primary ways to build neural network models: the Sequential API and the Functional API. The Sequential API stacks layers linearly — each layer has exactly one input and one output, and layers are added in order. It covers the majority of standard architectures: feedforward networks, simple CNNs, basic RNNs. The Functional API treats layers as callable functions applied to tensors, enabling architectures with shared layers, multiple inputs, multiple outputs, and branching topologies like ResNet's skip connections or multi-task models. Choosing between them is not a style preference — it is a structural requirement. A model where every layer connects exactly to the next is Sequential. A model with any fork, merge, skip, or multi-input is Functional. Understanding both APIs deeply means the gap between reading a research paper's architecture diagram and producing working code is measured in minutes, not hours.
30 minadvanced
Keras Sequential and Functional API
Analogy🏏Cricket
🏏 Think of it like cricket: The Duckworth-Lewis-Stern (DLS) method, the ICC bowling economy metric, and the net run rate each measure team performance but optimise for completely different things — DLS cares about wickets-in-hand, economy cares about runs-per-over, NRR cares about tournament-wide margins. Using the wrong metric to evaluate a bowler is like using MSE for classification: technically computable but optimising the wrong thing entirely. Just as you would never rank a spinner by batting average, you should never use MSE when your model predicts probabilities. Just as focal DLS adjustments down-weight easy chases and amplify close finishes, focal loss down-weights easy examples and amplifies hard minority-class examples. The choice of scoring metric defines what excellence means — and so does the choice of loss function.
Lesson 7 of 35
0% complete