Gradient flow and the kernel
Penguin learning project
The project uses 342 complete Palmer penguin records: 240 training-pool and 102 held-out rows. The selected training rows determine feature scaling and model parameters. Source CSV
This project trains weights with softmax, unlike the homepage lab, which uses nearest species averages. Same penguin measurements; different classification methods. Predictions can differ.
Kernels and linearization · Relate parameter gradients or features to kernel matrices.
The project supplies finite observations and fitted parameters. A held-out sample does not establish population bounds or prove a theorem.
Consider this concept alongside the project; its source assumptions may differ. These observations do not prove a theorem.
Input: 12 × 2; Held-out evaluation: 102 · #58 · 40.6 mm, 193 mm. Known answer: Adélie; Prediction: Adélie · [≈0.7383, ≈0.2444, ≈0.01737].
Used in these source sections: 2.1 A view through similarity
Gradient flow changes parameters in the negative risk-gradient direction. Each Dᵢ is the derivative of the loss with respect to the prediction.
For the toy model Φ(x,θ) = θx and squared loss, the code computes the parameter, prediction, and risk rates at one instant.
The kernel expresses how a parameter update changes predictions at different inputs.
Source formula example
illustration · This computes instantaneous rates for one smooth scalar model and two fixed samples. It does not solve the full trajectory or show that a general kernel stays constant.
Symbols
- Derivative of the loss with respect to the prediction on training example i.
- Dot product of output gradients at two inputs.
Source formula example
This source example uses its own inputs and assumptions. Editing it does not change the project.
Edit a value or the code, then run the example. This is a finite demonstration, not a proof of the paper’s theorem.
This example’s data flow
Code changed. Reset to restore this example’s data flow.
You choose
input.theta= 1input.query= 1
Initial values in code
xs=[1, 2]ys=[2, 4]
Calculated here
Result expression: {
predictions,
lossDerivatives,
parameterRate,
kernelRow,
kernelMatrix,
predictionRate,
riskRate,
}
predictions=xs.map((x) => input.theta * x)Uses:xs,input.thetalossDerivatives=predictions.map((value, i) => 2 * (value - ys[i]))Uses:predictions,ysparameterRate=-xs.reduce((sum, x, i) => sum + x * lossDerivatives[i], 0) / xs.lengthUses:xs,lossDerivativeskernelRow=xs.map((x) => input.query * x)Uses:xs,input.querykernelMatrix=xs.map((xi) => xs.map((xj) => xi * xj))Uses:xspredictionRate=-kernelRow.reduce((sum, value, i) => sum + value * lossDerivatives[i], 0) / xs.lengthUses:kernelRow,lossDerivatives,xsriskRate=-xs.reduce( (sum, xi, i) => sum + xs.reduce( (inner, xj, j) => inner + lossDerivatives[i] * xi * xj * lossDerivatives[j], 0, ), 0, ) / xs.length ** 2Uses:xs,lossDerivatives
Returns
predictions- array (2 items): [1, 2]
lossDerivatives- array (2 items): [-2, -4]
parameterRate- 5
kernelRow- array (2 items): [1, 2]
kernelMatrix- array (2 items): [array (2 items): [1, 2], array (2 items): [2, 4]]
predictionRate- 5
riskRate- -25
Read numbers from input and return the result. JavaScript basics.
Result
Technical statement
The source uses the chain rule to express parameter velocity, output velocity and risk velocity through D and the neural tangent kernel. This linear model has gradient ∂Φ/∂θ = x, hence kernel K(x,x′) = xx′. For squared loss, Dᵢ = 2(Φ(xᵢ,θ)−yᵢ). The risk rate equals minus the squared parameter gradient in this scalar example.
Source: Source expression