The Modern Mathematics of Deep Learningexplained for non-mathematicians

Gradient descent step

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.

Classification predicts three species; Ridge predicts body mass in grams using the same observations. These are separate models. Training predictions feed the objective; 102 separate test predictions never update the weights.

Learning and parameter updates · Select a rule or update parameters using a learning rule.

The current objective supplies a gradient; training updates the model parameters.

Update

Input
Gradient: [≈0.004056, ≈0.01907, ≈0.008327, ≈-0.008829, ≈-0.0138, ≈0.01504, ≈0.004773, ≈-0.005269, ≈-0.02337]; Step size: 0.1
Output
[≈-0.2899, ≈-2.054, ≈-1.017, ≈0.6924, ≈1.558, ≈-1.663, ≈-0.4025, ≈0.4955, ≈2.68]

Project operation

The project calculation uses these records; the source formula and example follow below. Code edits run locally; project settings travel between pages.

Gradient → Update → Prediction

Project input

Showing first three entries; the operation receives the complete array. Rounded preview; the operation uses full precision.

input.weights · Model
[≈-0.2895, ≈-2.052, ≈-1.016] … (9 entries)
input.gradient · Gradient
[≈0.004056, ≈0.01907, ≈0.008327] … (9 entries)
input.rate · Update
0.1

Result

[≈-0.2899, ≈-2.054, ≈-1.017] … (9 entries)

Used in these source sections: 1.2.1 Finding better settings · 2.3 The path matters

The gradient gives the direction in which the objective increases fastest. Subtract a scaled gradient to take a step.

For this toy objective r(θ) = θ², the gradient is 2θ.

The step is one basic way to reduce an objective.

Source formula example

θk+1=θk−η∇r(θk)\theta_{k+1}=\theta_k-\eta\nabla r(\theta_k)

illustration · This is one step on a particular quadratic. A step need not reduce every objective for every step size.

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

You choose

  • input.theta = 2
  • input.rate = 0.1

Calculated here

Result expression: { gradient, next, before: input.theta ** 2, after: next ** 2 }

  • gradient = 2 * input.theta Uses: input.theta
  • next = input.theta - input.rate * gradient Uses: input.theta, input.rate, gradient

Returns

Example result
gradient
4
next
1.6
before
4
after
2.56

Read numbers from input and return the result. JavaScript basics.

Result

Enable JavaScript to run this example.

Technical statement

Change the input and run the same code again. The displayed result uses the values shown above.

Source: Gradient descent