Recurrent Neural Chemical Reaction Networks That Approximate Arbitrary Dynamics
Recurrent Neural Chemical Reaction Networks That Approximate Arbitrary Dynamics
Abstract: Many important phenomena in chemistry and biology are realized via dynamical features
such as multi-stability, oscillations, and chaos. Construction of novel chemical systems with such
finely-tuned dynamics is a challenging problem central to the growing field of synthetic biology.
In this paper, we address this problem by putting forward a molecular version of a recurrent
artificial neural network, which we call a recurrent neural chemical reaction network (RNCRN).
We prove that the RNCRN, with sufficiently many auxiliary chemical species and suitable fast
reactions, can be systematically trained to achieve any dynamics. This approximation ability is
shown to hold independent of the initial conditions for the auxiliary species, making the RNCRN
more experimentally feasible. To demonstrate the results, we present a number of relatively simple
RNCRNs trained to display a variety of biologically-important dynamical features.
1 Introduction
Artificial neural networks (ANNs) are a set of algorithms, inspired by the structure and function
of the brain, which are commonly implemented on electronic machines [1]. ANNs are known for
their powerful function approximating abilities [2, 3], and have been successfully applied to solve
complex tasks ranging from image classification [4] to dynamical control of chaos [5]. Given the
success of ANNs on electronic machines, it is unsurprising that there has been substantial interest in
mapping common ANNs to chemical reaction networks (CRNs) [6–15] - a mathematical framework
used for modelling chemical and biological processes. In this paper, we say that a CRN is neural
if it executes an ANN algorithm. Neural CRNs have been implemented experimentally using a
range of molecular substrates [16–21]. As such, these networks, and other forms of chemically-
realized computing systems [22–28], intend to embed computations inside biochemical systems, where
electronic machines cannot readily operate.
Current literature on neural CRNs has focused on solving static problems, where the goal is to take
an input set of chemical concentrations and produce a time-independent (static) output. These static
neural CRNs find application as classifiers [29,30] in symbol and image recognition tasks [10,12,31,32],
complex logic gates [11, 20], and disease diagnostics [17]. However, more intricate time-dependent
(dynamical ) features can be of great importance in biology. In particular, under suitable conditions,
many biological processes can be modelled dynamically using ordinary-differential equations (ODEs).
In this context, fundamental processes such as cellular differentiation and circadian clocks are realized
via ODEs that exhibit features such as coexistence of multiple favourable states (multi-stability)
and oscillations [33–35]. In fact, even deterministic chaos, a complicated dynamical behaviour, is
thought to confer a survival advantage to populations of cells [35].
a
Email of co-corresponding authours: [email protected] or [email protected].
1
Department of Bioengineering and Imperial College Centre for Synthetic Biology, Imperial College London,
Exhibition Road, London SW7 2AZ, UK.
2
Department of Applied Mathematics and Theoretical Physics, University of Cambridge, Centre for Mathematical
Sciences, Wilberforce Road, Cambridge, CB3 0WA, UK.
1
Despite their promising potential in biology, neural CRNs trained to emulate such dynamical
behaviours remain largely unexplored in the literature. To bridge the gap, in this paper we present a
novel neural CRN called the recurrent neural chemical reaction networks (RNCRNs) (see Figure 1).
We prove that RNCRNs can approximate the dynamics of any well-behaved target system of ODEs,
provided that there are sufficiently many auxiliary chemical species and that these species react
sufficiently fast. A major advantage of RNCRNs over some other comparable methods for designing
chemical systems [36,37] is that the initial concentrations for the auxiliary species are not constrained.
This fact is important, since high-precision experimental fine-tuning of initial concentrations is
infeasible [38].
𝑌1
𝛽1
∅ 𝑋1 𝑌1 𝛾/𝜇
1/𝜇
∅ 𝑌1 ∅
𝑋1 + 𝑌1 𝜔1,1 𝜔1,0
𝜇 𝜇
𝑋1 𝑌1
∅ 𝑋1
𝛼1,1
𝑋1 ⋮
⋮
𝛼1,𝑀 𝑋1 + 𝑌𝑀 𝑌𝑀
𝑋1 ∅
𝜔𝑀,1
𝜇 1 /𝜇
𝑌𝑀 𝑌𝑀 ∅ 𝑌𝑀 ∅
𝜔𝑀,0 /𝜇 𝛾/𝜇
The paper is organized as follows. In Section 2, we present some background theory on CRNs and
ANNs. In Section 3, we introduce an RNCRN, and outline the main theoretical result regarding its
approximation properties; this result is stated rigorously and proved in Appendix A. A generalised
RNCRN is presented in Appendix B. In Section 4, we present an algorithm for training the RNCRN
as Algorithm 1, which we demonstrate by obtaining relatively simple RNCRNs displaying multi-
stability, oscillations and chaos; more details can be found in Appendix C. Finally, we provide a
2
summary and discussion in Section 5.
2 Background theory
In this section, we present some background theory on chemical reaction networks and artificial
neural networks.
In particular, according to the first reaction, when species X and Y react, one molecule of X is
degraded. Since the molecular count of Y remains unchanged when this reaction occurs, we say that
Y acts as a catalyst for the first reaction. The second reaction describes a production of X from
some chemical species which we do not explicitly model, and simply denote by ∅; similarly, the third
reaction describes production of Y . One molecule of Y is produced when X and Y react according
to the fourth reaction. In this reaction, X remains unchanged, and is therefore a catalyst. Finally,
according to the fifth reaction, when two molecules of Y react, one of the molecules is degraded.
Systems of chemical reactions, such as (1), are called chemical reaction networks (CRNs) [39].
Reaction-rate equations. In this paper, we make a standard assumption on the rate at
which the reactions occur: it given by the product of the concentrations of the underlying reactants
(species on the left-hand side of the reaction) multiplied by the rate coefficient - the positive number
displayed above the reaction arrow. This choice of rates is called the mass-action kinetics. For
example, let us denote the concentrations of X and Y from (1) at time t ≥ 0 respectively by x = x(t)
and y = y(t). The first reaction from (1) has α > 0 as its rate coefficient, and thus occurs at the rate
αxy. Similarly, the rates of the other four reactions from (1) are given by β, γ, ωxy and y 2 ; note
that for the final reaction, we have fixed the rate coefficient to 1. Under suitable conditions [39], the
concentrations of chemical species satisfy a system of ordinary-differential equations (ODEs) called
the reaction-rate equations (RREs). For system (1), the RREs are given by
dx dy
= β − αxy, = γ + ωxy − y 2 . (2)
dt dt
In what follows, we denote the chemical species by X1 , X2 , . . . , Y1 , Y2 , . . ., their corresponding
concentrations by x1 , x2 , . . . , y1 , y2 , . . . ≥ 0, and the rate coefficients of the underlying reactions using
the Greek letters α, β, γ, ω > 0 with appropriate subscript indices. For simplicity, we assume that all
the variables, including the rate coefficients, are dimensionless. Furthermore, we limit ourselves to
the chemical reactions with at most two reactants. In this case, the RREs have quadratic polynomials
on the right-hand side, as in (2). More general chemical reactions, with three or more reactants, are
experimentally unlikely to occur, and can be approximately reduced to reactions with at most two
reactants [40, 41].
3
called the activation function, to produce a single output. More precisely, let x1 , x2 , . . . , xN ∈ R
be the input values, ω1 , ω2 , . . . , ωN ∈ R be the weights, ω0 ∈ R a bias, and σ : R → R a suitable
non-linear function. Then, the perceptron is a function y : RN → R defined as
XN
y = y(x1 , . . . , xN ) = σ ωj xj + ω0 . (3)
j=1
Chemical perceptron. A natural question arises: Is there a CRN with single species Y such
that its RRE has a unique stable equilibrium of the form (3)? Such an RRE has been put forward
and analyzed in [14], and takes the following form:
N
dy X
=γ+ ωj x j + ω0 y − y 2 . (4)
dt
j=1
where s = sign( N
P
j=1 ωj xj + ω0 ), with function sign(·) yielding the sign of a real number. We call
species Y from (5) a chemical perceptron. Setting the left-hand side in (4) to zero, one finds that
there is a unique globally stable non-negative equilibrium, which we denote by y ∗ , given by
v u 2
N N u N
X 1 X u X
y ∗ = σγ ωj xj + ω0 ≡ ωj xj + ω0 + t ωj xj + ω0 + 4γ . (6)
2
j=1 j=1 j=1
We call σγ with γ > 0 a chemical activation function. As γ → 0, σγ approaches the rectified linear
unit (ReLU) activation function [14], which is a common choice in the ANN literature [4].
4
We call the CRN corresponding to the RREs (8) a recurrent neural chemical reaction network
(RNCRN). In Figure 1, we schematically display this RNCRN with N = 1. The RNCRN consists
of two sub-networks, the first of which is the executive sub-system, shown in purple in Figure 1,
which contains chemical reactions which directly change the executive species X1 , X2 , . . . , XN . Note
that the initial conditions for the executive species from (8) match the target initial conditions
from (7). The second sub-network is called the neural sub-system, shown in yellow in Figure 1, and
it contains those reactions which directly influence the auxiliary species Y1 , Y2 , . . . , YM , for which
we allow arbitrary initial conditions b1 , b2 , . . . , bM ≥ 0. These species can be formally identified as
chemical perceptrons, see (4)–(5). However, let us stress that the CRN (5) with RRE (4) depends
on the parameters x1 , x2 , . . . , xN . In contrast, the concentrations of chemical perceptrons from the
RNCRN depend on the executive variables x1 (t), x2 (t), . . . , xN (t), which in turn depend on the
perceptron concentrations y1 (t), y2 (t), . . . , yM (t). In other words, there is a feedback between the
executive and neural systems, giving the RNCRN a recurrent character. This feedback is catalytic in
nature: the chemical perceptrons are catalysts in the executive system; similarly, executive species
are catalysts in the neural system.
Main result. We now wish to choose the parameters in the RNCRN so that the concentrations
of the executive species xi (t) from (8) are close to the target variables x̄i (t) from (7). Key to achieving
this match is the parameter µ > 0, which sets the speedPat which the perceptrons equilibrate relative
to the executive sub-system. The equilibrium yj∗ = σγ ( N i=1 ωj,i xi + ωj,0 ), with σγ of the form (6), is
reached infinitely fast if we formally set µ = 0 in (8); we then say that the perceptrons have reached
the quasi-static state. In this case, the executive species are governed by the reduced ODEs:
M N
!
dx̃i X X
= gi (x̃1 , . . . , x̃N ) = βi + x̃i αi,j σγ ωj,k x̃k + ωj,0 , x̃i (0) = ai , for i = 1, 2, . . . , N.
dt
j=1 k=1
(9)
This reduced system allows us to prove that the RNCRN can in principle be fine-tuned to execute
the target dynamics arbitrarily closely. In particular, to achieve this task, we follow two steps.
Firstly, we assume that the chemical perceptrons are in the quasi-static state, i.e. we consider
the reduced system (9). Using the classical (static) theory from ANNs, it follows that the rate
coefficients from the RNCRN can be fine-tuned so that the vector field from the reduced system (9)
is close to that of the target system (7). To ensure a good vector field match, one in general requires
sufficiently many chemical perceptrons. We call this first step the quasi-static approximation.
Secondly, we disregard the assumption that the chemical perceptrons are in the quasi-static
state, i.e. we consider the full system (8). Nevertheless, we substitute into the full system the
rate coefficients found in the first step. Using perturbation theory from dynamical systems, it
follows that, under this parameter choice, the concentrations of the executive species from the full
system (8) match the variables from the target system (7), provided that the chemical perceptrons
fire sufficiently (but finitely) fast. We call this second step the dynamical approximation.
In summary, the RNCRN induced by (8) with sufficiently many chemical perceptrons (M ≥ 1
large enough) which act sufficiently fast (µ > 0 small enough) can execute any target dynamics.
This result is stated rigorously and proved in Appendix A; a generalization to deep RNCRNs, i.e.
RNCRNs containing multiple coupled layers of chemical perceptrons, is presented in Appendix B.
4 Examples
In Section 3, we have outlined a two-step procedure used to prove that RNCRNs can theoretically
execute any desired dynamics. Aside from being of theoretical value, these two steps also form a
5
basis for a practical method to train RNCRNs, which is presented as Algorithm 1. In this section,
we use Algorithm 1 to train RNCRNs to achieve predefined multi-stability, oscillations, and chaos.
Fix a target system (7) and target compact sets K1 , K2 , . . . , KN ⊂ (0, +∞). Fix also the rate
coefficients β1 , β2 , . . . , βN ≥ 0 and γ > 0 in the RNCRN system (8).
(a) Quasi-static approximation. Fix a tolerance ε > 0. Fix also the number of chemi-
cal perceptrons M ≥ 1. Using the backpropagation algorithm [44], find the coefficients
∗ , ω ∗ , ω ∗ for i = 1, 2, . . . , N , j = 1, 2, . . . , M , such that the mean-square distance between
αi,j j,0 j,i P
(fi (x1 , x2 , . . . , xN )/xi − βi /xi ) and M ∗ N ∗ ∗
P
j=1 αi,j σγ k=1 ωj,k xk + ωj,0 is within the tolerance
for (x1 , x2 , . . . , xN ) ∈ K1 × K2 × . . . × KN . If the tolerance ε is not met, then repeat step (a)
with M + 1.
4.1 Multi-stability
Let us consider the one-variable target ODE
dx̄1
= f1 (x̄1 ) = sin(x̄1 ), x̄1 (0) = a1 ≥ 0. (10)
dt
This system has infinitely many equilibria, which are given by x̄∗1 = nπ for integer values of n. The
equilibria with even n are unstable, while those with odd n are stable.
Bi-stability. Let us now apply Algorithm 1 on the target system (10), in order to find an
associated bi-stable RNCRN. In particular, let us choose the target region to be K1 = [1, 12], which
includes two stable equilibria, π and 3π, and one unstable equilibrium, 2π. We choose e.g. β1 = 0,
as this coincides with sin(0), and γ = 1.
Quasi-static approximation. Let us apply the first step from Algorithm 1. We find that the
tolerance ε ≈ 10−3 is met with M = 3 chemical perceptrons, if the rate coefficients αi,j , ωj,0 , ωj,i in
the reduced ODE (see (9)) are chosen as follows:
dx̃1
= g1 (x̃1 ) = − 0.983σ1 (−1.167x̃1 + 7.789) x̃1
dt
− 0.050σ1 (0.994x̃1 − 1.918) x̃1
+ 2.398σ1 (−0.730x̃1 + 3.574) x̃1 . (11)
In Figure 2(a), we display the vector fields of the target (10) and reduced system (11). One can
notice an overall good match within the desired set K1 = [1, 12], shown as the unshaded region. As
6
expected, the approximation is poor outside of K1 ; furthermore, for the given tolerance, the accuracy
is also reduced near the left end-point of the target set.
D % L V W D E O H G \ Q D P L F V E % L V W D E O H W U D M H F W R U L H V
f(x1 )
8π
x̄ 1 (t)
g(x1 ) 7π x1 (t)
6π
9 H F W R U I L H O G
5π
x1 (t)
4π
3π
2π
π
0 π 2π 3π 4π 5π 6π 7π 8π 0
6 W D W H x1 7 L P H t
F 7 U L V W D E O H G \ Q D P L F V G 7 U L V W D E O H W U D M H F W R U L H V
f(x1 )
8π
x̄ 1 (t)
g(x1 ) 7π x1 (t)
6π
9 H F W R U I L H O G
x1 (t) 5π
4π
3π
2π
π
0 π 2π 3π 4π 5π 6π 7π 8π 0
6 W D W H x1 7 L P H t
Figure 2: RNCRN approximations of a multi-stable non-polynomial target system. (a) The vector
field of the target system (10) and reduced system (11) when K1 = [1, 12]. (b) Solutions x̄1 (t) of the
target system (10), and x1 (t) of the full system (12) with µ = 0.01. Analogous plots are shown in
panels (c) and (d) for the tri-stable RNCRN over K1 = [1, 18] from Appendix C.1, whose reduced
and full ODEs are given respectively by (28) and (29), with coefficients (27) and µ = 0.01. In panels
(c) and (d), the initial concentrations of all chemical perceptrons are set to zero.
Dynamical approximation. Let us apply the second step from Algorithm 1. Using the coefficients
from (11), we now form the full ODEs (see (8)):
dx1
= −0.983x1 y1 − 0.050x1 y2 + 2.398x1 y3 , x1 (0) = a1 ∈ K1 ,
dt
dy1
µ = 1 − 1.167x1 y1 + 7.789y1 − y12 , y1 (0) = b1 ≥ 0,
dt
dy2
µ = 1 + 0.994x1 y2 − 1.918y2 − y22 , y2 (0) = b2 ≥ 0,
dt
dy3
µ = 1 − 0.730x1 y3 + 3.574y3 − y32 , y3 (0) = b3 ≥ 0. (12)
dt
We fix the initial conditions arbitrarily to b1 = b2 = b3 = 0, the desired final-time to T = 5 and
the perceptron speed to µ = 0.01. We numerically integrate (10) and (12) over t ∈ [0, 5] for a fixed
initial concentration a1 ∈ K1 of the executive species, and plot the solutions x̄(t) and x(t); we then
repeat the same computations for various values of a1 , which we display in Figure 2(b). One can
notice that the RNCRN underlying (12) with µ = 0.01 accurately approximates the time-trajectories
of the target system; in particular, we observe bi-stability.
7
Tri-stability. Let us now apply Algorithm 1 on (10) to obtain a tri-stable RNCRN. To this end,
we consider a larger set K1 = [1, 18], which includes three stable equilibria, π, 3π, and 5π, and two
unstable equilibria, 2π and 4π. Applying Algorithm 1, we find an RNCRN with M = 4 chemical
perceptrons, which with µ = 0.01 displays the desired tri-stability; see Figure 2(c)–(d), and see
Appendix C.1 for more details. In a similar manner, Algorithm 1 can be used to achieve RNCRNs
with arbitrary number of stable equilibria.
4.2 Oscillations
Let us consider the two-variable target ODE system
dx̄1 3
= f1 (x̄1 , x̄2 ) = 6 + 4J0 x̄1 − x̄2 , x̄1 (0) = a1 ≥ 0,
dt 2
dx̄2
= f2 (x̄1 , x̄2 ) = x̄1 − 4, x̄2 (0) = a2 ≥ 0, (13)
dt
were J0 (x̄1 ) is the Bessel function of the first kind. Numerical simulations suggest that (13) has an
isolated oscillatory solution, which we display as the blue curve in the (x̄1 , x̄2 )-space in Figures 3(a);
also shown as grey arrows is the vector field, and as the unshaded box we display the desired region
of interest K1 × K2 = [0.1, 12] × [0.1, 12]. In Figure 3(c)–(d), we show as solid blue curves this
oscillatory solution in the (t, x̄1 )- and (t, x̄2 )-space, respectively.
Using Algorithm 1, we find an RNCRN with M = 6 chemical perceptrons, whose dynamics
with µ = 0.01 qualitatively matches the dynamics of the target system (13) within the region of
interest; see Appendix C.2 for details. We display the solution of this RNCRN as the purple curve
in Figures 3(b)–(d).