Machine Learning

Bernoulli Natural Gradient

Compare Euclidean and Fisher-scaled updates without hiding invalid probabilities.

By Riano · Published · Updated · Report a correction

Bernoulli Natural Gradient

When training probabilistic models, the parameter space is often better measured using information geometry rather than standard Euclidean distance. For a Bernoulli parameter p, this module compares the ordinary gradient descent update with the natural gradient step.

Worked Example

Consider a Bernoulli model with initial probability p = 0.5 and soft target q = 0.25. We want to take a step size eta = 0.5.

  1. Calculate Cross Entropy Loss:
    L = -q * ln(p) - (1-q) * ln(1-p) = -0.25 * ln(0.5) - 0.75 * ln(0.5) = -ln(0.5) ≈ 0.6931
  2. Calculate Ordinary Gradient:
    dL/dp = (p - q) / (p * (1 - p)) = (0.5 - 0.25) / (0.5 * 0.5) = 0.25 / 0.25 = 1
  3. Calculate Ordinary Raw Probability Update:
    p_new_ordinary = p - eta * dL/dp = 0.5 - 0.5 * 1 = 0
  4. Calculate Fisher Information:
    I(p) = 1 / (p * (1 - p)) = 1 / (0.5 * 0.5) = 4
  5. Calculate Natural Gradient Update:
    p_new_natural = p - eta * (p - q) = 0.5 - 0.5 * (0.5 - 0.25) = 0.5 - 0.125 = 0.375

In this example, both steps stay within the valid probability domain, but the natural gradient scales the update using the Fisher information matrix to navigate the curved probability space more effectively. This provides a substantive visible explanation for the calculation.

Experiment

Interact with the module at https://riano.app/module/bernoulli-natural-gradient to see how gradient scaling affects the probability update.

  1. Set Initial probability to 0.1.
  2. Set Target probability to 1.
  3. Set Step size to 0.5.
  4. Observe that the ordinary raw update jumps to 5.1, moving far outside the valid probability domain.
  5. Notice the natural gradient step keeps the new probability at a valid 0.55.

This experiment demonstrates the stability of natural gradient updates.

Limitations and Assumptions

This simulation uses the exact closed decimal grid and scaled integer fractions to classify true endpoint updates. However, it's important to note that parameterization invariance describes the infinitesimal natural-gradient field, not exact equality of arbitrary finite Euler steps in p and logit coordinates. Large step sizes (like eta = 1) can still push parameters to exact boundary limits where cross-entropy becomes zero or mathematically unavailable. These assumptions form the boundaries of the model's predictive power.

References

The following external sources support the formulation of the natural gradient.

These external references are fundamental for understanding natural gradients and Fisher information matrices as applied in this visualization module.

Experience it interactively

Adjust parameters, observe in real time, and build deep intuition with Riano’s interactive Bernoulli Natural Gradient module.

Try Bernoulli Natural Gradient on Riano →

More in Machine Learning