  Gauge invariance plays a crucial role in quantum mechanics from condensed
matter physics to high energy physics. We develop an approach to constructing
gauge invariant autoregressive neural networks for quantum lattice models.
These networks can be efficiently sampled and explicitly obey gauge symmetries.
We variationally optimize our gauge invariant autoregressive neural networks
for ground states as well as real-time dynamics for a variety of models. We
exactly represent the ground and excited states of the 2D and 3D toric codes,
and the X-cube fracton model. We simulate the dynamics of the quantum link
model of $\text{U(1)}$ lattice gauge theory, obtain the phase diagram for the
2D $\mathbb{Z}_2$ gauge theory, determine the phase transition and the central
charge of the $\text{SU(2)}_3$ anyonic chain, and also compute the ground state
energy of the $\text{SU(2)}$ invariant Heisenberg spin chain. Our approach
provides powerful tools for exploring condensed matter physics, high energy
physics and quantum information science.
