We construct a field theory in 1+1 dimensions for the training of deep residual networks, with the depth of the network as space and the training time as time. Its field equations, the master system, are derived as the continuum limit of gradient descent and of the heavy-ball method, for any width and any form of the blocks: at each depth the parameters obey the damped equation of motion of the optimizer, driven by the product of the error and the activation, while the activations and the errors obey the forward and adjoint equations along depth. The master system is the Hamilton system of a Bateman-Galley doubled action, in which the network is a set of constraints imposed by the errors as fields. In synchronous training, the forward and the backward pass are the secondary constraints of Dirac's algorithm, and backpropagation follows from the Dirac bracket. A finite speed of the signals along depth describes pipelined training: it turns the constraints into transport equations and makes the error the momentum of an activation, and the closed-time-path structure of the action selects the pairing in which the errors are causal. As solutions and limits of the master system, the theory recovers several results of the training theory of deep learning, among them backpropagation as an adjoint equation, the depth scaling of the learning rate, and the stability of delayed and pipelined training with weight prediction, and it gives a stability bound near a minimum that holds for any network: training is stable when the round trip of the signals is shorter than pi/2 times the fastest relaxation time of the output. Numerical tests on deep tanh networks confirm the continuum limit, and a Dirac flow computed by automatic differentiation alone reproduces backpropagation in time and depth.