  The Gillespie algorithm is commonly used to simulate and analyze complex
chemical reaction networks. Here, we leverage recent breakthroughs in deep
learning to develop a fully differentiable variant of the Gillespie algorithm.
The differentiable Gillespie algorithm (DGA) approximates discontinuous
operations in the exact Gillespie algorithm using smooth functions, allowing
for the calculation of gradients using backpropagation. The DGA can be used to
quickly and accurately learn kinetic parameters using gradient descent and
design biochemical networks with desired properties. As an illustration, we
apply the DGA to study stochastic models of gene promoters. We show that the
DGA can be used to: (i) successfully learn kinetic parameters from experimental
measurements of mRNA expression levels from two distinct $\textit{E. coli}$
promoters and (ii) design nonequilibrium promoter architectures with desired
input-output relationships. These examples illustrate the utility of the DGA
for analyzing stochastic chemical kinetics, including a wide variety of
problems of interest to synthetic and systems biology.
