Statistical mechanics studies systems with huge numbers of interacting parts, which describes the parameters of a neural network well. The bridge is that a Bayesian posterior over parameters has exactly the form of a Boltzmann distribution.
We will treat loss as energy, read losses as likelihoods, and finish with choosing a loss as choosing a noise model.
Step 1: Loss as energy
A Gibbs posterior weights each parameter setting by its loss:
This is a Boltzmann distribution with energy nL(w) and inverse temperature β. Temperature controls how strongly the loss matters. As β → 0 (high temperature) the loss stops mattering and the posterior becomes the prior; as β → ∞ (low temperature) it concentrates on the minimizers of the loss, recovering ordinary training. β = 1 is ordinary Bayesian inference.
Step 2: Losses are likelihoods
Most training losses are negative log-likelihoods of some noise model. If y = f(x) + noise with Gaussian noise of variance σ², then −ln p(y | x) = (y − f)² ÷ (2σ²) + constant. So training with squared loss (y − f)² at inverse temperature β is exactly Bayesian inference when β = 1 ÷ (2σ²): β = 0.5 corresponds to noise variance 1. Choosing β is implicitly choosing how noisy you believe the data are.
Step 3: Choosing a loss, choosing a noise model
The same correspondence works for other losses. Absolute error |y − f| is the negative log-likelihood of Laplace noise, which has heavier tails, so it is less disturbed by outliers. Cross-entropy is −ln of the probability a categorical model assigns to the correct class. And the normalizer Z of the Gibbs posterior gives the free energy −ln Z, the negative log marginal likelihood, so the machinery of statistical mechanics (free energies, phase transitions, fluctuations) applies directly to learning.