Two Ways to Tame a Spike

BackpropagationMedium+20 XP+20

Two Ways to Tame a Spike

A small model has trained calmly for hundreds of steps. Then one batch produces a gradient spike, and the backward pass returns this gradient for the model's four weights:

g=(0.6, −9.0, 0.8, 12.0)g = (0.6,\ -9.0,\ 0.8,\ 12.0)g=(0.6, −9.0, 0.8, 12.0)

Two teammates each propose a clipping rule. Both use the same limit, 111.

rulewhat it does to ggg
A: clip by normif ∥g∥>1\lVert g \rVert > 1∥g∥>1, rescale the whole vector: g←g⋅1∥g∥g \leftarrow g \cdot \dfrac{1}{\lVert g \rVert}g←g⋅∥g∥1​
B: clip by valueclamp each entry separately into [−1, 1][-1,\ 1][−1, 1]: entries above 111 become 111, entries below −1-1−1 become −1-1−1, the rest are left alone

Here ∥g∥=g12+g22+g32+g42\lVert g \rVert = \sqrt{g_1^2 + g_2^2 + g_3^2 + g_4^2}∥g∥=g12​+g22​+g32​+g42​​ is the ordinary length of the vector. Whichever rule is used, its output replaces ggg in the update, and the weights move against it.

What is the angle, in degrees, between the vector that Rule A produces and the vector that Rule B produces?

Round to 1 decimal place. Carry at least four decimals through the intermediate steps.

Hints

Solve it to unlock the solution

Once you get it right, the reasoning behind the answer shows up here.