augmented-neural-odes icon indicating copy to clipboard operation
augmented-neural-odes copied to clipboard

Solving parameterized ODE for prediction

Open d-j-kendall opened this issue 4 years ago • 4 comments

Once I have trained the ODEFun, how can I make future time prediction as an initial value problem if the network does not accept first and second derivative initial values?

Or is this project only considering first order ODEs?

d-j-kendall avatar Oct 26 '19 23:10 d-j-kendall

Hi, this project is indeed only considering first order ODEs. However, if you have a higher order ODE requiring first or second derivative initial values, you can always rewrite it as a first order ODE system. See e.g. these lectures notes for a nice explanation and examples.

So you can solve ODE systems of any order (and so requiring any number of initial conditions) with this project since you can solve ODE systems of any size.

EmilienDupont avatar Nov 01 '19 11:11 EmilienDupont

Ok thank you, I have seen this before. So I modified the network to take 4 inputs (position, velocity, t0, t1) then output a position in the future based on t0 and t1, would this be the correct structure?

I also ignored the time_dependent flag as I ported in my own time values, but does this change the underlying structure of the network?

I am trying to predict a position for a time that can be up to a minute from t0, what would be the best way to go about training a network like this.

Sorry if this question seems simple.

d-j-kendall avatar Nov 02 '19 21:11 d-j-kendall

I guess the part I am not understanding is when I am defining the dataset class, what exactly the inputs and targets should be.

My data looks like so

{"cls": 0, "cnf": 0.8342911005020142, "x": 1024.0, "y": 740.0, "xv": -3000.0, "yv": 4600.0, "t": 5.36}
{"cls": 0, "cnf": 0.8501971960067749, "x": 989.5, "y": 788.0, "xv": -3450.0, "yv": 4800.0, "t": 5.37}
{"cls": 0, "cnf": 0.7614980936050415, "x": 796.5, "y": 907.0, "xv": -5300.0, "yv": 1800.0, "t": 5.41}
{"cls": 0, "cnf": 0.6145259737968445, "x": 747.0, "y": 918.5, "xv": -4950.0, "yv": 1150.0, "t": 5.42}

the "x", "y" values are the centroid of an object on the screen in pixels.

The "xv", "xy" values are an object's differential speed, arbitrarily in pixels/second.

So I am trying to model the position of the object as a function of time with this project.

The data above is 1 trial, but I have several trials tracking the motion of this object and would like to generalize the network to learn this motion for given initial conditions (x,y,xv,yv,t0) then it generate a prediciton for any tN.

Screenshot from 2019-11-03 12-17-15

Each of the following files represents a trial.

I thought about creating a set of parametric equations and networks separately for X and Y values.

Could you shed some light on the best way to do this?

If you are interested, my senior design group is trying to gain a statistical advantage in roulette using computer vision.

https://github.com/dkendall100/beating_roulette

d-j-kendall avatar Nov 03 '19 18:11 d-j-kendall

If I understand correctly, you have the position x0 and the velocity v0 of an object at some time t0 and you would like to predict its position and velocity at some time t1. In this situation, the initial conditions would be [x0, v0], and you would solve the ODE from time t0 to t1.

The time_dependent flag can still be used even if you have your own time values. The time_dependent flag only modifies the type of ODE you can learn. If time_dependent=False, then the model will learn an ODE of the type

dh(t)/dt = f(h(t))

and if time_dependent=True, then it will learn an ODE of the form

dh(t)/dt = f(h(t), t)

i.e. the ODE function will depend explicitly on time.

In this code repo, we only focus on learning ODEs on the interval from t=0 to t=1. However, you can easily modify this. If you look at the ODEBlock class, you can see that there is an eval_times parameter in the forward method. This can be used to evaluate the model at arbitrary times. So for example, you could have your roulette ball position at some time t=t0 with initial conditions [x0, y0, xv0, yv0]. You could then use the ODEBlock forward method with eval_times=[t0, t1], so that the model solves the ODE from t0 to t1. You could then compare the model's prediction at t1 with the actual measured value at t1.

Hope this helps!

EmilienDupont avatar Nov 07 '19 16:11 EmilienDupont