WorksMathematics
Neural ODE’s - Theory and Application: From Residual Networks to Continuous-Depth Dynamics
Abstract
This paper explores Neural Ordinary Differential Equations (Neural ODE’s) and then applies them to a real-world example of bacteria growth. We solve the population Initial Value Problem analytically using Bernoulli form and then compare it to the dynamics learned by a neural network. We demonstrate that Neural ODE’s can accurately reconstruct continuous, dynamic systems from discrete data.
Los Altos Hills, CA
Introduction
Residual Networks
In 2015, Residual Networks were introduced by Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun.1 ResNets allowed for the training neural networks using discrete layers, a process identical to Euler’s Method for solving ODE’s.
Then, in 2018, Chen et al. proposed Neural ODE’s, which took the limit of ResNet layers as step size approached zero. Essentially, this work parameterized the derivative of a hidden state in the neural network, further allowing for continuous-time modeling.2

Figure 1. Residual Networks define a discrete sequence of transformations whereas Neural ODE networks learn the dynamics of a vector field to continuously transform its state (Chen et al.).
We will apply ODE techniques, like Bernoulli forms to solve initial value problems, to the field of Machine Learning and Mathematical Biology.
Background Knowledge
The Research Question
Now that we know Neural ODE’s attempt to learn continuous dynamics, it would not be wrong to question the relevance of this. In comparison to ResNets, Neural Networks define the rate of change of output rather than just the output. This means that the Network is learning a vector field rather than a static map. Furthermore, when trying to make a prediction to calculate the next data point from initial input , we must solve an Initial Value Problem given by
where is a Neural Network parameterized by .1
However, instead of solving this equation analytically, Neural Networks computationally solve the ODE using numerical integration methods. Specifically, they use methods like Euler’s Method or Runge Kutta to approximate integration.2
This brings us to the research question: How can we continuously predict successive data points with a Neural ODE, and how accurate will it be?
Chapter 2
Summary of ODE Techniques
Bernoulli Differential Equations
A key to answering the focus question lies in the Bernoulli form. To recap, a non-linear, first-order ODE can be classified as a Bernoulli ODE if it is given in the form
The reason that this is so special is that Bernoulli ODE’s can be solved relatively simply. The steps to solve Bernoulli ODE’s are as follows:
Divide by :
Define variable substitution, let
then
Multiply the ODE:
Make substitution:
Solve for using integrating factor
Substitute back for and find implicit/explicit solutions
This is the algorithm for analytically solving Bernoulli ODE’s. However, in the example next, we will show how Neural ODE’s can forego this process using a training phase.
Example and Model Derivation
Bacteria Population
In Mathematical Biology, states of systems like population size are tracked over time. Here are some field concepts that will be helpful to know:
Vector Field: A map that assigns some direction and magnitude at every point in the space
This is what the Neural ODE will learn
Carrying Capacity (): The maximum population size that an environment can sustain with limited resources
Intrinsic Growth Rate (): How fast the population grows given unlimited resources
In simple population models with unlimited resources, exponential growth occurs. However, since resources are finite in the real world, we must model population using a logistic model given by:
When population is small, the term and the growth of is exponential. However, as population approaches carrying capacity , the term approaches , thus stopping growth of .
Problem Setup and Solution
Suppose we aim to find the population function given the following parameters:
(growth rate per hour)
(carrying capacity of 10 bacteria units)
(initial bacteria unit population)
Therefore, we can model the initial value problem as such
Compared to the Bernoulli form, we can identify , , and .
Let’s now follow the steps to solve Bernoulli ODE's:
Define variable substitution, let
then
Now multiply the ODE by and substitute:
This is now a linear, first-order ODE! To solve this linear equation, we calculate the Integrating Factor, :
Now multiply the entire linear equation by :
We recognize the left side as the derivative of the product :
Now integrate both sides:
Solving for :
Now we can substitute back for :
Finally, let’s apply our initial conditions , knowing that and :
Solving for the arbitrary constant term :
Substituting back into the general solution gives the specific solution:

Figure 3.1. Sigmoid Function representing Bacteria Growth
And finally, we have constructed our logistic population growth model with a particular solution. This solution and graph will be the benchmark that the Neural ODE will be trained against.
Chapter 4
Predictions
Neural ODE Construction and Limitations
Using our derived model , we predict the population at time hours:
After 10 hours, the bacteria population will be about 6.01 units. Note: The model assumes that and are constant, but in reality, carrying capacity often fluctuates with the environment. We also assumed that the population is large enough to be treated as continuous, which would not hold for small populations (like discrete individuals). Additionally, Neural ODE’s are often computationally expensive, so the limitations of using these networks include the capabilities of computer hardware.
With this in mind, let’s find the end result after training a Neural ODE with 1000 iterations. See Appendix § 10 for code files.
Conclusion
As you can see, at hours, the Neural ODE path runs through , which we predicted with our analytical Bernoulli solution.

Figure 2. Output of neuralode.py
By treating the Neural ODE as a learned vector field of an ODE, we successfully modeled the Logistic Growth of a bacteria population with limited resources. Both the Neural ODE and the Bernoulli Differential Equation techniques yielded a sigmoid curve that stabilized once carrying capacity was hit.
An Invitation for Further Exploration
Suppose the carrying capacity was not constant, but a periodic function that changed with the seasons. Let
How would the solution to the Bernoulli Equation change, and would Neural ODE’s be a superior method to solving this new equation?
Code Files

Figure A.1. Neural ODE Code File Page 1

# Generate "True" training data
true_model = LogisticGrowth(r=0.5, K=10.0)
# We compute true data using the analytical solution (Bernoulli result)
true_y = true_model.analytical_solution(y0, t)
# Now train with 1000 iterations
func = ODEFunc()
optimizer = optim.Adam(func.parameters(), lr=0.01)
n_iters = 1000
print("Training Neural ODE on Logistic Growth...")
for i in range(n_iters):
optimizer.zero_grad()
# Forward Pass: Integrate NN using RK4
pred_y = rk4_solve(func, y0, t)
# Compute Loss (MSE)
loss = torch.mean((pred_y - true_y)**2)
loss.backward()
optimizer.step()
if i % 100 == 0:
print(f"Iter {i:04d} | Loss {loss.item():.6f}")
print("Training Complete!")
# Visualize the data
t_np = t.detach().numpy().flatten()
true_y_np = true_y.detach().numpy().flatten()
pred_y_np = pred_y.detach().numpy().flatten()
plt.figure(figsize=(10, 6))
plt.title("Neural ODE Learning Logistic Growth (Bernoulli Example)")
# Plot True Data (The Analytical Solution)
plt.plot(t_np, true_y_np, 'g-', label='Analytical Solution (Bernoulli)', linewidth=4, alpha=0.4)
# Plot Neural ODE Prediction
plt.plot(t_np, pred_y_np, 'k--', label='Neural ODE (Learned)', linewidth=2)
# Plot Carrying Capacity line
plt.axhline(y=10.0, color='r', linestyle=':', label='Carrying Capacity K=10')
plt.xlabel("Time")
plt.ylabel("Population")
plt.legend()
plt.grid(True, alpha=0.3)
plt.show()
# Verification: Predict outside training range (Extrapolation)
print("\nVerifying 'Carrying Capacity' behavior...")
last_val = pred_y_np[-1]
print(f"Final Population at t={t_max}: {last_val:.4f} (Should be close to K=10.0)")Figure A.2. Neural ODE Code File Page 2
References
- [1]Chen, Ricky T. Q., Yulia Rubanova, Jesse Bettencourt, and David Duvenaud. Neural Ordinary Differential Equations, 2019. arXiv: 1806.07366 [cs.LG]. https://arxiv.org/abs/1806.07366.
- [2]He, Kaiming, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep Residual Learning for Image Recognition, 2015. arXiv: 1512.03385 [cs.CV]. https://arxiv.org/abs/1512.03385.
- [3]Valperga, Ricardo, and Miltos Kofinas. “DS - Dynamical Systems and Neural ODEs,” 2023. https://uvadlc-notebooks.readthedocs.io/en/latest/tutorial_notebooks/DL2/Dynamical_systems/dynamical_systems_neural_odes.html.
- [4]Zeltkevic, Michael. “Runge-Kutta Methods,” 1998. https://web.mit.edu/10.001/Web/Course_Notes/Differential_Equations_Notes/node5.html.