Fields in Space
A vector field assigns a vector to every point in space. Think of wind patterns on a weather map, or water currents in the ocean. At each location, there is a direction and magnitude.
In ML, the most important vector field is the gradient field. At every point in parameter space, the gradient tells us which direction increases the loss fastest.
Gradient Fields
The gradient of a scalar function forms a vector field. If is a loss surface, then is the gradient field.
Conservative Fields
Gradient fields are conservative. The line integral between two points is path independent. This means there is a well defined "potential" (the loss function) that we are descending.
Gradient Descent as Flow
Gradient descent follows the streamlines of the negative gradient field: . We flow "downhill" toward the minimum.
Interactive Simulator
Explore different vector fields. Toggle streamlines to see how a particle would flow through the field.
Vector Field Simulator
Gradient Descent (Sink)
Ideally, gradients point toward a minimum. This is a stable equilibrium.
Interactive Inspect
Hover over the field to see the exact vector at that point.
Divergence
Divergence measures how much a vector field "spreads out" at a point. It is a scalar field derived from a vector field.
div F > 0
Source: vectors spread outward
div F < 0
Sink: vectors converge inward
div F = 0
Incompressible: no net flow
Divergence Visualizer
Positive Divergence (Source)
Vectors spread outward. Think of a faucet: water is being 'created' (entering the 2D plane) at the origin.
Geometric Intuition
Curl
Curl measures the rotation or "swirl" of a vector field around a point.
Gradient Fields Have Zero Curl
If , then . This is because mixed partials are equal: .
Curl Intuition: The Paddlewheel
Try dragging the paddlewheel (Shear flow is tricky!)
Vortex Field
Pure rotation. The classic example of positive curl.
Mathematical Curl
In 2D, Curl is a scalar (Z-component of torque).
Positive = Counter-Clockwise.
Negative = Clockwise.
Paddlewheel Physics
Case Study: Navigating Loss Landscapes
You train a neural network to predict bulb lifespan. The loss function L(θ) defines a surface in high-D parameter space. Let's understand gradient descent as flow.
Step 1: Define the Loss Surface
The loss function maps parameters to a scalar loss value. This creates a "landscape" in parameter space.
Step 2: Compute the Gradient Field
At every point θ, compute . This vector points "uphill" toward increasing loss.
Step 3: Follow the Negative Gradient
Move in direction to descend the loss. This is gradient descent: flowing downhill through the gradient field.
Step 4: Watch for Saddle Points
Where , we've found a critical point. The Hessian eigenvalues tell us if it's a minimum (all positive) or saddle (mixed signs).
ML Applications
Gradient Flow
Continuous-time gradient descent: dθ/dt = -∇L. The solution traces a path through the gradient field. Used in Neural ODE analysis.
Normalizing Flows
Transform probability distributions using invertible vector fields. The change in density involves the determinant of the Jacobian.
Physics-Informed NNs
Encode PDEs (involving div, curl, grad) as loss terms. The network learns solutions to physical equations.
Score Matching (Diffusion)
Learn the score function ∇log p(x) via a neural network. This is the gradient of the log-density. Diffusion models use this to generate samples.