- Home
- Library
- Computational Quantum Field Theory
- Predicting Observables across Parameters
- Neural Networks and Training Objectives
Neural Networks and Training Objectives
A small training loss is not a complete physical result. A network may miss an exact zero, violate a response identity, or stop before its requested optimization tolerance. We can inspect all three possibilities on the finite scalar response and compare them with ordinary interpolation on exactly the same labels.
Preparation: The reference scalar observable, the baseline comparison, and the chain rule underlying automatic differentiation.
A network for two specified outputs
The input is for the two-site periodic scalar with . The target is , with . Use two hidden layers of width , each with a hyperbolic tangent, followed by a two-component linear output:
Rows represent examples; has shape . Counting weights and biases gives
real parameters. The physical predictions are
The output architecture enforces positivity of , but it does not enforce or source parity. Those are separate physical checks.
For fixed training labels, minimize
Biases are not penalized. This loss expresses a chosen balance between mean-field error and multiplicative susceptibility error. It is not a likelihood inferred from quadrature noise: the reference labels are deterministic high-accuracy integrals. With genuinely noisy labels, a declared Gaussian covariance would instead lead to a quadratic residual weighted by its inverse, including cross-example correlations if present. Estimating or ignoring that covariance changes the objective; calling an arbitrary squared loss a physical likelihood would hide an assumption.
Derive the gradient that is actually optimized
Let contain layer- activations for all examples, with and . Define the output adjoint
The derivative of is . Therefore backward propagation gives
where denotes elementwise multiplication. The parameter derivatives are
For the final layer the same weight and bias formulas use and ; there is no output activation derivative. These equations are the ordinary backward chain rule. Rumelhart, Hinton and Williams, pp. 533–535, Eqs. (1)–(9) (PDF), present the layered squared-loss construction with a logistic activation. The tanh derivative and optimizer used here are explicit choices for this example.
A useful check must test more than two copies of this vectorized formula. The companion evaluates a tiny network by independent scalar loops. Five fixed parameter directions compare the analytic directional derivative against central differences with steps from to . Every direction reaches an error below ; the expected truncation decrease and eventual roundoff increase are retained. A separate production-network input derivative check differs from finite differences by less than . Packing and unpacking all parameters is checked exactly.
Frozen optimization and independent evaluation
Five initializations use zero biases and independent Gaussian weights with variance . Their seeds are SeedSequence([941025,20,k]) for . Each is optimized once by L-BFGS-B without parameter bounds, using the analytic gradient above. The fixed caps are iterations and function evaluations, with maxls=40, maxcor=20, ftol=1e-14 and gtol=1e-7.
The two stopping tests have different meanings: a small relative objective change can stop a run without satisfying the gradient criterion. The SciPy 1.13.1 L-BFGS-B documentation defines these tests and caps. Here all five runs reach the iteration limit. Their returned status is unsuccessful, and an independent final gradient evaluation confirms that none meets the requested maximum-component tolerance. No run is restarted or replaced by a more favorable seed.
Accepted-iterate training and monitor losses are retained. The monitor points do not stop training or select a checkpoint. The final test points are not available to optimization. The table reports physical test RMSE and the final objective-gradient norm:
| Initialization | RMSE in | RMSE in | |
|---|---|---|---|
| Five-model transformed-output mean | — | ||
| Zero-initialized control |
The ensemble averages , not the two physical outputs after exponentiation. Thus its is the arithmetic average of individual , while its is the geometric average of individual . Initialization SD is neither a standard error of a measured observable nor a Bayesian posterior without further assumptions.
The zero-initialized control has all weights and biases initially zero. It reaches the constant-output stationary solution in one iteration and satisfies the gradient target, yet predicts poorly. This is a deliberately retained counterexample to identifying successful optimization with a useful representation. Its derivation appears in Exercise 1.
Training and monitor losses for five fixed initializations, with the same optimizer budget. All random runs reach iterations before the requested gradient tolerance. The constant zero-initialized control converges quickly but has much larger physical error. Test values never select an iteration.
These finite-budget neural fits are less accurate than the cubic spline's susceptibility RMSE on this regular-grid test. They still demonstrate a trainable representation with checked derivatives. Neither greater width nor a lower training loss alone establishes an advantage over the appropriate baseline.
Exact zeros and identities that the loss does not impose
Relative error in is ill-defined at . The separate diagnostic set contains , each at , , and . We use absolute errors when and report relative errors only on the remaining points. Across the random networks, the maximum near-zero absolute mean-field error ranges from to . A smooth-looking curve can therefore miss a tiny physical response by many times its magnitude. No denominator floor is used to disguise this as a finite relative error at zero.
The scaled input also matters when testing the response relation. Since ,
The physical defect is . Its test RMS ranges from to across the five runs. The outputs were trained separately, so this is a substantive residual rather than a contradiction.
A secondary source-parity projection is possible:
The first expression makes exactly, and the second yields an even positive susceptibility after exponentiation. These are prediction-only projections, not retrained models. They reduce the observed response-defect RMS to – here, but do not make it vanish. The saved raw parity diagnostics are explicitly defects in and , not and physical .
The active example retains every primary network's weights, stopping status and history in observable-network.json. Running observable_network.py --fit deliberately retrains the frozen study; its default mode only verifies and evaluates saved weights. This separation permits a figure or a prediction to be reproduced without silently running a new optimization.
Summary
Backpropagation supplies the gradient of a declared loss, not a guarantee of physical accuracy. This example separates reference errors, representation choices, finite optimization, initialization variation, near-zero diagnostics and exact identities. All five random fits miss the requested convergence target; a different stationary control succeeds numerically while failing as a predictor.
Exercises
1. Why can zero initialization fail at a stationary point?
For the two-hidden-layer tanh network and weight penalty above, set every weight to zero and the first two biases to zero. Show that optimizing only the output bias reaches a stationary point of the full objective. Is it necessarily a global minimum?
Solution
Both hidden activations vanish, so for every input. The output-bias derivative is , hence minimizes the constant-predictor loss. The output-weight gradient is , since . Propagating through gives , and then . All remaining weight gradients and hidden-bias gradients vanish as well.
Thus the point is stationary for the entire parameter vector. Its data loss is the target variance divided according to the declared normalization; it need not be small. A nonconstant network can fit varying targets better, so stationarity is not a global-minimum certificate. The experiment realizes this trap: a tiny gradient coexists with susceptibility RMSE about .
2. Symmetry does not imply the fluctuation relation
Derive the source derivative of . Give a parity-correct positive pair that still violates .
Solution
The chain rule on the reflected argument gives
The second derivative symbol on the right means differentiation with respect to the function's own source argument before evaluating it at . In scaled network coordinates this is .
For a simple counterexample take and . The first is odd, the second positive and even, yet . Source parity constrains transformation laws; the fluctuation relation couples derivatives of one observable to another. It would need a different representation, such as consistent derivatives of a learned generating function, or an additional explicitly stated constraint. Such a model would still require accuracy checks.
References
- D. E. Rumelhart, G. E. Hinton and R. J. Williams, “Learning representations by back-propagating errors,” Nature 323 (1986), 533–536, Eqs. (1)–(9) (author-hosted PDF).
- SciPy developers, minimize(method='L-BFGS-B'), SciPy 1.13.1 documentation, stopping tests and iteration/evaluation limits.
Scrollable formula. Use Left and Right arrow keys to reveal hidden content.
Scrollable table. Use Left and Right arrow keys to reveal hidden columns.
Scrollable figure. Use Left and Right arrow keys to reveal hidden content.