Skip to content
QFT.org

Search QFT.org

Enter a word or phrase.

    You can also browse the main navigation and chapter contents.

    Normalizing Flows for Fields

    An independent random number is easy to generate. An independent field configuration with the right correlations is harder. A normalizing flow addresses this problem by transforming a simple random vector through an invertible map. The map supplies both a configuration and its probability density, which makes the approximation testable and, with an acceptance step, correctable.

    We first construct an exact correlated Gaussian field on two sites. We then replace the linear map by a trained nonlinear map for an interacting field. Independent draws from that map need not have the target distribution: the accompanying calculation includes a striking case in which a flow misses an entire well.

    Preparation: Gaussian covariance, changes of variables and a positive Euclidean weight. The examples use dimensionless lattice variables and ordinary Lebesgue measure.

    An exact correlated field from two independent normals

    Consider a periodic two-site scalar with lattice spacing one and action

    S(ϕ)=∑i=01[12(ϕi+1−ϕi)2+r2ϕi2+λ24ϕi4],ϕ2=ϕ0.S(\phi)=\sum_{i=0}^1\left[\frac12(\phi_{i+1}-\phi_i)^2 +\frac r2\phi_i^2+\frac\lambda{24}\phi_i^4\right], \qquad \phi_2=\phi_0.

    The two kinetic terms are both present. Introduce orthonormal coordinates

    Q=ϕ0+ϕ12,R=ϕ0−ϕ12.Q=\frac{\phi_0+\phi_1}{\sqrt2},\qquad R=\frac{\phi_0-\phi_1}{\sqrt2}.

    Their absolute Jacobian is one, and the action becomes

    S(Q,R)=r2Q2+r+42R2+λ48(Q4+6Q2R2+R4).S(Q,R)=\frac r2Q^2+\frac{r+4}{2}R^2 +\frac\lambda{48}(Q^4+6Q^2R^2+R^4).

    For the free case λ=0\lambda=0, r=2r=2, draw z0,z1z_0,z_1 independently from the unit normal and set

    (ϕ0ϕ1)=A(z0z1),A=12(111−1)(1/2001/6).\begin{pmatrix}\phi_0\\\phi_1\end{pmatrix} =A\begin{pmatrix}z_0\\z_1\end{pmatrix}, \qquad A=\frac1{\sqrt2} \begin{pmatrix}1&1\\1&-1\end{pmatrix} \begin{pmatrix}1/\sqrt2&0\\0&1/\sqrt6\end{pmatrix}.

    Then Q=z0/2Q=z_0/\sqrt2 and R=z1/6R=z_1/\sqrt6. Multiplying AATAA^T gives

    ⟨ϕϕT⟩=(1/31/61/61/3),∣det⁡A∣=112.\langle\phi\phi^T\rangle= \begin{pmatrix}1/3&1/6\\1/6&1/3\end{pmatrix}, \qquad |\det A|=\frac1{\sqrt{12}}.

    The neighboring fields are correlated even though the input numbers were independent. The density is

    q(ϕ)=ρ(A−1ϕ)∣det⁡A∣=122πe−S(ϕ),Z=2π12,q(\phi)=\frac{\rho(A^{-1}\phi)}{|\det A|} =\frac{\sqrt{12}}{2\pi}e^{-S(\phi)}, \qquad Z=\frac{2\pi}{\sqrt{12}},

    where ρ(z)=e−∣z∣2/2/(2π)\rho(z)=e^{-|z|^2/2}/(2\pi). This is an exact transport, with no training and no discretization of the field values. It is still a finite two-site regulator.

    A map must carry its measure

    Let f:Rd→Rdf:\mathbb R^d\to\mathbb R^d be a differentiable bijection with nonzero Jacobian determinant. Conservation of probability between corresponding volume elements gives

    q(x) ddx=ρ(z) ddz,x=f(z),q(x)\,\mathrm d^d x=\rho(z)\,\mathrm d^d z, \qquad x=f(z),

    and therefore

    log⁡q(x)=log⁡ρ(f−1(x))−log⁡∣det⁡Df(f−1(x))∣.\log q(x)=\log\rho(f^{-1}(x)) -\log|\det Df(f^{-1}(x))|.

    The inverse is needed when evaluating the density at an arbitrary field, including a current Markov-chain state that the map did not generate. For a composition f=fL∘⋯∘f1f=f_L\circ\cdots\circ f_1, the log determinant is the sum of the layer log determinants, each evaluated at its own input [1, §§III.2–III.6].

    An invertible map also carries support. A Gaussian base and a globally invertible map onto Rd\mathbb R^d give a positive density everywhere. This prevents an exactly excluded open region, but it does not prevent assigning that region an astronomically small probability. Positive support is a mathematical condition; practical exploration is a separate question.

    Affine coupling gives a tractable inverse

    Split the current coordinates into a frozen part xax_a and an updated part xbx_b. An affine coupling layer is

    ya=xa,yb=es(xa)xb+t(xa).y_a=x_a,\qquad y_b=e^{s(x_a)}x_b+t(x_a).

    Once yay_a is known, its inverse is explicit:

    xa=ya,xb=e−s(ya)[yb−t(ya)].x_a=y_a,\qquad x_b=e^{-s(y_a)}[y_b-t(y_a)].

    The Jacobian is triangular,

    ∂y∂x=(10es(xa)s′(xa)xb+t′(xa)es(xa)),log⁡∣det⁡Df∣=s(xa).\frac{\partial y}{\partial x}= \begin{pmatrix} 1&0\\ e^{s(x_a)}s'(x_a)x_b+t'(x_a)&e^{s(x_a)} \end{pmatrix}, \qquad \log|\det Df|=s(x_a).

    Conditioner derivatives matter for gradients and the full Jacobian, even though the determinant depends only on its diagonal. Alternating the frozen coordinate allows both coordinates to change. A network inside a conditioner need not itself be invertible; the layer is inverted by holding its conditioner input fixed [1, §IV.3, equations (13)–(16)].

    Our interacting map has six alternating layers. Each conditioner has one input, sixteen tanh⁡\tanh hidden units and two outputs, with

    s=.8tanh⁡us,t=2tanh⁡ut.s=.8\tanh u_s,\qquad t=2\tanh u_t.

    There are 396 real trainable parameters. A final fixed scaling (x0,x1)↦(2x0,x1)(x_0,x_1)\mapsto(2x_0,x_1) produces (Q,R)(Q,R) and adds log⁡2\log2 to the determinant. Bounded scales and shifts preserve the explicit inverse. The model does not impose the target's sign symmetry, so an imbalance is observable rather than hidden by construction.

    The nonlinear map is a proposal for an interacting field

    Set λ=4\lambda=4, zero source, and compare r=2,−1,−4r=2,-1,-4. The exact target is p=Z−1e−Sp=Z^{-1}e^{-S}. For negative rr, the two uniform classical minima are

    R=0,Q=±−3r.R=0,\qquad Q=\pm\sqrt{-3r}.

    The origin-to-minimum action difference is 3r2/43r^2/4. The strongest example has a barrier of 12, while the finite-volume target still satisfies ⟨Q⟩=0\langle Q\rangle=0 and P(Q>0)=1/2P(Q>0)=1/2. Reference moments come from the checked two-site scalar calculation, with a new quadrature refinement only for the additional r=−1r=-1 point.

    The next article performs the training. Its first reverse-KL fit at r=−4r=-4 produces no positive-QQ configuration in 16,384 fresh model draws. A forward-KL fit produces a positive-sector fraction of 0.49290.4929. Both maps are invertible and have full support. Their different behavior comes from the learned probability allocation, not from a failure of the change-of-variables formula.

    Exact scalar Q density compared with the first reverse-trained and forward-trained proposal densities at three fixed couplings.

    The target and the two learned proposals at fixed two-site volume and λ=4\lambda=4. Target curves integrate the checked action over RR; proposal histograms use the 16,384 retained independent draws from each delivered map. The strong-barrier reverse fit concentrates in one well. These are model draws, before Metropolis correction.

    The companion checks the nonlinear inverse, density identity and full finite-difference Jacobian at fixed nontrivial parameters. Round-trip errors are below 4×10−154\times10^{-15} and the density identity differs by less than 1.2×10−131.2\times10^{-13} on the tested points. These tests validate the implementation on those inputs; the separate target comparisons assess its learned distribution. Saved parameters can be checked and plotted without retraining.

    Summary

    A normalizing flow transforms both configurations and volume elements. The Gaussian example supplies an exact correlated field; affine coupling layers preserve an explicit inverse and density in the interacting example. Independent proposal draws are independent under qq, and become target draws only when q=pq=p or an appropriate correction succeeds. Continue to training against the action to see how the map is fitted and how its failures are measured.

    Exercises

    1. A nonlinear triangular layer

    For independent unit normals z0,z1z_0,z_1, define x0=z0x_0=z_0 and x1=eaz0z1+bz02x_1=e^{az_0}z_1+bz_0^2. Find the inverse, full Jacobian and normalized density. Are x0x_0 and x1x_1 independent when their covariance vanishes?

    Solution

    The inverse is z0=x0z_0=x_0, z1=e−ax0(x1−bx02)z_1=e^{-ax_0}(x_1-bx_0^2). The forward Jacobian is

    (10aeaz0z1+2bz0eaz0).\begin{pmatrix}1&0\\ae^{az_0}z_1+2bz_0&e^{az_0}\end{pmatrix}.

    Thus

    q(x)=e−ax02πexp⁡[−x022−e−2ax0(x1−bx02)22].q(x)=\frac{e^{-ax_0}}{2\pi} \exp\left[-\frac{x_0^2}{2} -\frac{e^{-2ax_0}(x_1-bx_0^2)^2}{2}\right].

    Integrating x1x_1 first gives the unit-normal density of x0x_0, so the total integral is one. Conditionally, x1x_1 has mean bx02bx_0^2 and variance e2ax0e^{2ax_0}. Its covariance with x0x_0 is zero: the noise term has zero conditional mean and Ez03=0\mathbb E z_0^3=0. Nevertheless its conditional law depends on x0x_0 unless a=b=0a=b=0. Zero covariance is not independence for this nonlinear distribution.

    2. Change the free mass

    Repeat the free two-site construction at r=3r=3. Find the site covariance, determinant and normalized density. What is the integral of the expression obtained by omitting the determinant factor?

    Solution

    The normal modes have variances 1/31/3 and 1/71/7. Therefore

    C=(5/212/212/215/21),∣det⁡A∣=121,q(ϕ)=212πe−S(ϕ).C=\begin{pmatrix}5/21&2/21\\2/21&5/21\end{pmatrix}, \qquad |\det A|=\frac1{\sqrt{21}},\qquad q(\phi)=\frac{\sqrt{21}}{2\pi}e^{-S(\phi)}.

    The expression ρ(A−1ϕ)\rho(A^{-1}\phi) integrates to ∣det⁡A∣=1/21|\det A|=1/\sqrt{21}, not one. Dividing by that integral restores the determinant factor and the covariance above. The covariance follows from AATAA^T, not from treating the two correlated site variables as independent normals.

    References

    1. M. S. Albergo et al., “Introduction to Normalizing Flows for Lattice Field Theory,” arXiv:2101.08176v3 (2021). Full text. §§III.2–III.6 derive transformed densities and composition; §IV.3 constructs affine coupling layers. The present action uses the explicitly stated λ/24\lambda/24 convention.

    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.