Module 11: Network Architecture Design
This module is about wiring. Real datasets mix numbers and categories, and a single input stack rarely fits them well. Through a passenger-survival case study you will move from the Sequential API to the Functional API, give each feature its own encoding path (raw, bucketed, one-hot, embedded), merge them into one network, and finish with a model that has more than one output.
Learning Objectives
- Establish rule-based baselines before building any network.
- Build the same model with the Sequential and Functional APIs and explain when only Functional will do.
- Encode numeric features raw or bucketed (Discretization) and justify the choice.
- Encode categorical features as one-hot vectors or learned embeddings.
- Combine multiple named inputs into one model and read its parameter count.
- Add a second output head and train it jointly with per-head losses.
The module in two minutes
An animated overview of the module’s through-line. Watch it before the lecture — it is the map, not the territory.
Lecture shorts
Short lectures and code walkthroughs from the instructor that reinforce this module. Some open partway into a longer video — that chapter is the part matched to this module.
Visual shorts
Short silent animations, one idea each. Press play, or open one full screen. All visual shorts
Orientation audio
Architecture as a design decision — wiring a network around the data you actually have.
The through-line
Every network so far was a stack: one input tensor, layers in a line, one output. That is the Sequential API, and it is enough — until the data stops being one homogeneous block. A passenger manifest mixes ages and fares (numbers) with sex and cabin class (categories), and this module’s question is architectural: how do you wire a network around the data you actually have?
The Functional API is the answer, and it is a small shift with large consequences. Layers become functions you call on tensors, inputs get names, and a model is whatever graph you wire from inputs to outputs. Stacks turn out to be the special case; branches, merges, and multiple heads come free. And plot_model draws the graph you built — the drawing is the design document.
Different columns deserve different front doors. A number can flow in raw, or a Discretization layer can bucket it when its effect is not smooth, so the model learns a separate effect per range. Categories become one-hot vectors, or embeddings — module 9’s idea pointed at any categorical column: a learned vector per category, parameters spent so that categories the task treats alike can land near each other.
With each input’s path wired, Concatenate merges them into a shared trunk, and the trunk can feed more than one head — predict survival and a second target, each head with its own loss, trained jointly as a weighted sum. The lecture climbs exactly this ladder in five models: one input, bucketed input, multiple named inputs, embedded categoricals, multiple outputs.
The discipline stays the course’s. Baselines first — majority class, then a one-rule model — because a network that cannot beat one honest rule is decoration. And read the parameter count the way you read a bill: every wiring choice prices in parameters, and the count tells you what you bought.
Four features, one survival model. Choose each feature’s front door, then read the wiring and the bill. The trunk is Dense(16); every parameter count is exact.
Nothing here is hidden: every choice reprices the network. Bucketing and one-hot cost width but zero parameters; an embedding buys geometry for its categories at a price you can read; the second head costs 51 parameters and changes what the trunk is asked to learn. The Functional API exists because this diagram is a graph, not a stack — the notebook wires the real thing and trains it. (One wrinkle there: Keras lookup layers reserve an out-of-vocabulary slot, so the notebook’s one-hot widths run one wider. Same arithmetic.)
Key concepts
- Functional API: Models as graphs of layers, not stacks
- Named Inputs: One Input per feature, matched by name
- Discretization (Bucketing): A number becomes a category when its effect is not smooth
- Embedding (tabular): A learned vector per category
- Multi-Output Model: Several heads, per-head losses, joint training
- Baseline: The rule to beat before wiring anything
The lecture notebook
Six parts, wired in Keras end to end — baselines, both APIs, then the five-model ladder. Run every cell; change things and rerun — the notebook is the lecture.
In Colab: File → Save a copy in Drive keeps your work.
Exercise
Attempt the exercise before opening the solution — the attempt is where the learning happens.
Knowledge check
The quiz is self-graded and open-book. If a question surprises you, the corresponding lecture part is the fastest fix.
Reference and discussion
One more thing belongs here. In this course, regularization and hyperparameter tuning are not a lecture week — they run as a practice thread through the assignments: learning curves, grid and random search, early stopping, keras-tuner. The dial below is that whole thread in one motion; it pairs with module 1’s memorizer.
A degree-9 polynomial on ten noisy points — module 1’s memorizer. Now add the L2 penalty: loss + λ·Σw². Slide λ and watch the weights get taxed into line.
At λ = 0 the curve threads every training point and the coefficient bars are enormous — training error near zero, validation error terrible. As λ grows the weights shrink smoothly (L2’s signature; L1 would zero some outright), the curve calms, and validation error dips before rising again when the penalty starves the fit. Choosing λ is a hyperparameter search — done on validation folds, never on the test set, which stays untouched until the end.
Finish the module
Complete the stages above, then claim the finish here.