Neural Networks, Deployment and Responsible ML
See how neural networks stack the ideas from this course, then learn what deploying a model involves: monitoring, data drift, fairness and documentation.
Welcome back!
Step 1 of 12Learn
Neural networks: stacked logistic regressions
You've already met the building blocks of a neural network. A single artificial neuron computes a weighted sum of its inputs plus a bias and applies an activation function: exactly what logistic regression does with the sigmoid. A neural network stacks many such units in layers:
- The input layer holds the features.
- Hidden layers each compute weighted sums of the previous layer's outputs and apply a nonlinear activation, most often ReLU: max(0, z).
- The output layer produces the prediction: one number for regression, a sigmoid for binary classification, or a softmax over classes.
Why stack layers? A single linear layer can only draw linear boundaries. Adding hidden layers with nonlinear activations lets the network represent curved, complex functions; with enough hidden units, a network can approximate essentially any reasonable function. Without nonlinear activations, though, stacking layers is pointless: a chain of linear functions collapses into a single linear function.
Training uses everything from this course:
- A loss function: MSE for regression, cross-entropy for classification.
- Backpropagation: an efficient application of the calculus chain rule that computes the gradient of the loss for every weight.
- Mini-batch gradient descent, usually with an adaptive optimizer such as Adam.
- Regularization: weight decay (L2), dropout, early stopping and data augmentation.
- Validation to tune hyperparameters such as layer sizes and learning rate.
Specialized architectures add structure for specific data: convolutional networks for images, which reuse the same small filters across an image, and transformers for sequences such as text, which use attention to relate every position to every other.
Step 2 of 12Practice · Diagram
A small neural network, left to right
Where does the nonlinearity that lets the network learn curves come from?
Tap the shape that answers the question, then press Check.
- Input layer
One value per feature, e.g. 4 inputs.
- Hidden layer 1 (ReLU)
Each neuron: weighted sum + bias, then max(0, z).
- Hidden layer 2 (ReLU)
Combines the first layer's features into more complex ones.
- Output
Sigmoid for yes/no, softmax over classes, or a plain number for regression.
Step 3 of 12Practice · Work it out
A fully connected layer takes 4 inputs and has 3 neurons, each with its own bias. How many learnable parameters (weights plus biases) does the layer have?
Step 4 of 12Learn
When to use deep learning, and when not to
Deep learning dominates headlines, but it isn't always the right tool.
Deep learning tends to win when:
- The data is unstructured: images, audio, video, free text.
- There's a lot of it, or a large pretrained model you can adapt.
- Useful features are too complex to engineer by hand.
Classical methods often win when:
- The data is tabular: rows of customers, transactions or sensor readings with meaningful columns. Gradient-boosted trees are frequently as accurate or more accurate, train in minutes on a laptop, and need less tuning.
- The dataset is small: hundreds or a few thousand rows.
- Interpretability is required, for example in credit decisions where reasons must be given.
- Compute or latency budgets are tight.
Transfer learning changed the economics. Instead of training from scratch, you start from a model pretrained on a huge dataset, such as an image model trained on millions of photos or a language model trained on vast amounts of text, and fine-tune it on your smaller dataset. A few hundred labeled images can then produce a useful classifier, because the pretrained layers already detect general features like edges, textures and shapes.
A sensible workflow for a new problem: establish a simple baseline; try a strong classical model such as gradient boosting for tabular data; try a pretrained deep model for unstructured data; compare all of them with the same validation procedure. Let the evidence, not the trend, pick the winner.
Step 5 of 12Compare
Deep learning vs. gradient-boosted trees
| Aspect | Deep learning | Gradient-boosted trees |
|---|---|---|
| Data type | Images, audio, text | Tables of columns |
| Data needed | Large, or a pretrained model | Hundreds to millions of rows |
| Compute | GPUs often needed | A laptop is usually enough |
| Explainability | Harder | Easier (feature importance) |
| Feature engineering | Learned automatically | Still helps a lot |
Step 6 of 12Practice · Sort into groups
For each project, which approach is the more natural first choice?
Tap an item, then tap its group (or drag it there).
Step 7 of 12Learn
Deployment: the model meets the world
A model that performs well in a notebook has only started its working life. Deployment means integrating it into a product or process, and new problems appear.
Training-serving skew. Features must be computed in production exactly as they were in training. If training used a customer's "total purchases in the last 30 days" computed from a clean nightly table, but production computes it from a live stream with a different definition, predictions quietly degrade.
Data drift. The world changes. Covariate drift is a change in the input distribution: a new customer segment, a new phone camera, a pandemic changing shopping habits. Concept drift is a change in the relationship between inputs and the target: fraudsters adopt new tactics, so the old patterns no longer signal fraud. Either way, yesterday's model becomes stale.
Monitoring catches these problems:
- Track input feature distributions and compare them with training data.
- Track prediction distributions: a sudden jump in the share of "high risk" predictions deserves a look.
- Track real performance once true labels arrive, which may take days or months.
- Set alerts and plan for retraining on fresh data, on a schedule or when drift is detected.
Feedback loops. Predictions can change the data you later train on. A model that decides which loans to approve only ever sees repayment outcomes for approved applicants. A recommendation system that shows only popular items makes them more popular. Designing around these loops, for example by occasionally exploring, keeps future training data informative.
Teams use MLOps practices, the machine learning equivalent of DevOps, to version data and models, automate retraining and roll back bad releases.
Step 8 of 12Diagram
Life after deployment
Tap a shape with to see more.
- Deploy
Same feature code as training, to avoid training-serving skew.
- Monitor inputs and outcomes
Input distributions, prediction rates, and real accuracy once labels arrive.
- Detect drift
Covariate drift (inputs change) or concept drift (the relationship changes).
- Retrain on fresh data
- Validate before release
The new model must beat the current one on recent held-out data.
Step 9 of 12Practice · Sort into groups
Classify each situation as covariate drift (inputs change) or concept drift (the input-output relationship changes).
Tap an item, then tap its group (or drag it there).
Step 10 of 12Learn
Responsible machine learning
Machine learning systems increasingly make or shape decisions about people: who gets a loan, which résumés are read, which patients get extra care. Responsible practice is part of doing the job well, not an optional extra.
Fairness. Models learn patterns from historical data, including historical discrimination, and proxies such as zip code can carry information about protected traits even when those columns are removed. Measure performance and outcomes by group: approval rates, error rates, calibration. Note that different fairness definitions, such as equal approval rates versus equal error rates, can conflict mathematically, so choosing among them requires discussion with the people affected and attention to the law.
Transparency and explanation. Document what the model does, what data trained it, how it was evaluated and where it should not be used. Model cards and datasheets for datasets are widely used templates. For individual decisions, explanation tools can show which features pushed a prediction up or down.
Privacy. Collect only what you need, protect it, and remember that models can sometimes memorize and leak training data. Techniques such as anonymization, aggregation and differential privacy reduce risk.
Human oversight. For high-stakes decisions, keep a person in the loop who can review, override and correct the model, and give affected people a way to contest decisions.
Robustness and security. Test on edge cases and shifted data. Some models can be fooled by carefully crafted inputs, called adversarial examples.
Frameworks such as the NIST AI Risk Management Framework and laws such as the EU AI Act set expectations for risk management, documentation and oversight, especially for high-risk uses.
Step 11 of 12Practice · Select all that apply
A team is about to deploy a model that ranks job applicants. Which practices are part of responsible deployment? Select all that apply.
Select all that apply.
Step 12 of 12Practice · Choose one
A churn model performed well for a year, but its precision has steadily declined over the last three months even though the code has not changed. What is the most likely cause?
Lesson complete!