Home▸Data Science▸Gradient Surgery: Resolving Conflicting Task Gradients (PCGrad)

Gradient Surgery: Resolving Conflicting Task Gradients (PCGrad) — 2D

Interactive 2D canvas: two toy quadratic task-loss bowls share one parameter point. Watch a naive gradient sum panel and a PCGrad gradient-surgery panel run side by side on the same conflicting landscape, with raw and projected gradient vectors drawn live.

Data Science2DAdvanced60 FPS📱 Mobile-adapted🌍 Earth⇄ 3D version
2d-ds-topic-75 ↗ Open standalone

In multi-task learning, a single shared parameter vector must satisfy every task's loss at once, and when two tasks' gradients point in opposing directions the naive sum of their gradients can partially cancel — or even move backward on one task. This 2D canvas renders two toy quadratic task losses as contour rings around independent optima, lets you dial a conflict angle between them, and runs a naive-sum panel side by side with a PCGrad "gradient surgery" panel on the identical landscape: projecting out the conflicting component of one task's gradient onto the other's normal plane before summing. Run the optimizer and watch each panel's trajectory trail and live loss/step telemetry to see exactly when and why gradient surgery helps.

⚙ Under the hood

Adjust the conflict angle and learning rate to see how two tasks' gradients interact, then compare Naive Sum vs. PCGrad's corrected combined update.

multi-task learningpcgradgradient surgerynegative transferoptimizationmachine learning

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)