# Neural ODE with irregular Data Observations?

**URL:** <https://discourse.julialang.org/t/neural-ode-with-irregular-data-observations/121544>\
**Category:** Machine Learning\
**Tags:** question\
**Created:** [October 21, 2024, 5:26pm UTC](https://discourse.julialang.org/t/neural-ode-with-irregular-data-observations/121544 "2024-10-21T17:26:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrickm663](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/patrickm663/32/202187_2.png) [@patrickm663](https://discourse.julialang.org/u/patrickm663)\
**Post date:** [October 21, 2024, 5:26pm UTC](https://discourse.julialang.org/t/neural-ode-with-irregular-data-observations/121544/1 "2024-10-21T17:26:09Z")

</div>

Hi

I have a dataset where the observed data is measured at irregular timesteps. I would like to use a neural ODE to interpolate and forecast.

At the moment, I am using a feed-forward NN with fairly good success, however the time dimension makes me think a neural ODE may help when forecasting.

Are there any ‘gotchas’ when handling irregular time steps, or would I need to look at a different architecture altogether?

Thanks.

---

<div class="post-metadata">

**Author:** ![dmetivie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmetivie/32/6926_2.png) [@dmetivie](https://discourse.julialang.org/u/dmetivie)\
**Post date:** [October 21, 2024, 10:29pm UTC](https://discourse.julialang.org/t/neural-ode-with-irregular-data-observations/121544/2 "2024-10-21T22:29:36Z")

</div>

I think NeuralODEs are a good fit when dealing with irregular time steps, nothing in the architecture enforce regular time steps.  
Whereas RNN or other classic architecture on the opposite requires regular time steps.

In [DiffEqFlux.jl](https://docs.sciml.ai/DiffEqFlux/stable/) you would need to `saveat` your time steps when computing the loss.

As for gotchas, if you use MSE for the loss, you might overweight the importance of a region where you have a lot of points compare to region with less data. One possible fix would be to consider a loss with an integral of the MSE (that you could estimate using Integrals.jl). (Note that for regular time steps this integral loss should be very much like the usual MSE).

---

<div class="post-metadata">

**Author:** ![patrickm663](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/patrickm663/32/202187_2.png) [@patrickm663](https://discourse.julialang.org/u/patrickm663)\
**Post date:** [October 22, 2024, 12:52pm UTC](https://discourse.julialang.org/t/neural-ode-with-irregular-data-observations/121544/3 "2024-10-22T12:52:51Z")

</div>

Thank you for your reply! I am going to do some testing over on my problem but it sounds doable now.
