Deep kernels and TracIn: learned features, and the training rows behind a prediction
A deep kernel lets a small network learn the features a Gaussian process compares rows on. TracIn traces a network's prediction back to the training rows whose steps helped or hurt it, using the checkpoints saved while it trained.
What runs in CodeSplash
- Gaussian process Verified in Python and R
You will be able to
- Say what a deep kernel learns and why it can overfit small tables
- Read a deep-kernel fit next to a fixed kernel with the cross-validated score
- Explain what a TracIn score adds up and how to read proponents, opponents and self-influence
Let the network pick the features
ReadA Gaussian process compares rows through its kernel. With a Matérn or radial basis kernel, closeness is plain distance on the standardized features. A deep kernel puts a small network in front: it maps each row to a few learned features, and the radial basis kernel compares rows on those.
The network and the kernel settings are trained together on the same log marginal likelihood as the other kernels, by small Adam steps, with a standard normal prior on the network's weights. CodeSplash takes those steps the same way in Python and R, so both engines land on the same model.
The settings you can change
Read| Setting | What it controls |
|---|---|
| Hidden units | Width of the network's hidden layer; 0 makes the learned features a straight projection |
| Learned features | How many features the network produces for the kernel |
| Training epochs, Learning rate | How long and how fast the network and kernel settings are trained together |
Can a deep kernel overfit?
PredictPredict first
A deep kernel has many more settings than a Matérn kernel's three. On a table with 100 rows, what's the risk?
Reveal
Overfitting. The marginal likelihood guards a kernel with a few settings well, but a network's weights give it room to move the training rows wherever the likelihood likes. Compare cross-validated scores before you trust a deep kernel on a small table.
Reading a fit
ReadOzone from solar radiation, wind and temperature, with 8 hidden units and 2 learned features:
| Deep kernel | |
|---|---|
| Cross-validated RMSE | 20.8 |
| 90% predictive intervals covering held-out rows | 0.753 |
| Log marginal likelihood (final model) | −52.6 |
The Kernel settings table lists the signal and noise SD, the network's size and the epochs it trained. There's no lengthscale: the network's last layer sets the scale of the learned features. With Hidden units at 0, the learned features are a projection of the inputs, a cheap middle ground (temperature from ozone, wind and month: cross-validated RMSE 5.91).
When a deep kernel is still improving at its last epoch, the result says so. More epochs may fit better, but check the cross-validated score, not only the likelihood.
Which training rows made this prediction?
ReflectA dense network (Neural network (MLP)) saves checkpoints while it trains: its weights at the last epoch and at the best one. Training rows behind it (TracIn) in the run's Explain tab uses them. For each explained row and each training row it adds up, over the checkpoints, the learning rate times the dot product of the two rows' loss gradients.
Proponents, opponents and self-influence
Read- A positive score marks a proponent: that row's training steps lowered the explained row's loss.
- A negative score marks an opponent: its steps raised it.
- Self-influence, a row's score with itself, is large for rows the network found hard to fit. Look there first for unusual or mislabeled rows.
TracIn uses the checkpoints the run kept, so with one distinct checkpoint it reduces to a gradient dot product at the final weights. A registered copy of a model leaves its checkpoints with the training run, so trace it from the run.
Check your understanding
CheckpointCheck yourself
What does a deep kernel learn that a Matérn kernel doesn't?
Show the answer
Answer: a
The network maps each row to a few learned features, and the radial basis kernel measures closeness on those instead of on the raw standardized features.
Check yourself
A deep kernel's log marginal likelihood is far higher than the Matérn kernel's, but its cross-validated RMSE is worse. Which do you keep?
Show the answer
Answer: b
A network can raise the likelihood by bending its features around the training rows. Held-out rows show whether that helps new predictions.
Check yourself
In TracIn's table, training row 41 has the largest self-influence and a different label from its nearest neighbors. What's a sensible next step?
Show the answer
Answer: a
High self-influence means the network found the row hard to fit. That often points to a labeling error or an unusual case, which deserves a look before any change.
Set it up
In the appIn Predict, choose Gaussian process, set Kernel to Deep kernel (learned features), and adjust Hidden units and Learned features in the model settings (epochs and learning rate are under the advanced ones). For TracIn, train a Neural network (MLP), open the run's Explain tab and choose Training rows behind it (TracIn).
Recap
Recap- A deep kernel learns the features a Gaussian process compares rows on; it can overfit, so judge it by the cross-validated score.
- Both engines train it with the same small Adam steps from the same starting weights.
- TracIn adds up learning rate × gradient dot products over a network's saved checkpoints: proponents help a prediction, opponents hurt it, high self-influence flags hard rows.
Concepts in this lesson