EmilienDupont / augmented-neural-odes

Pytorch implementation of Augmented Neural ODEs :sunflower:
MIT License
527 stars 88 forks source link

Confusion about eval_times #3

Closed anandijain closed 4 years ago

anandijain commented 5 years ago

Hello again, I'm pretty new to neural ODEs and differential equations in general. I hope I'm not wasting your time as this may be a sort of dumb question.

I am trying to learn the functions that govern the light curves of astronomical objects for my internship according to this data spec. Eventually, I am going to try and classify the light curves (and use the other parameters they give), but for now I want to understand just how to learn the function for brightness over time (for a given object). So this I believe is going to be 1-Dimensional data per time point.

Right now I have a DataLoader with a getitem() that gives me a ([352, 2], class id) tensor where the first axis is the time values corresponding to the brightness (flux) at that time. I was going to do it this way so that I could try to learn the light curve functions in batches (my intuition is that the ODE might be able to better estimate the curves of one object based on how it evaluated others).

I see that for the Trainer class, you provide an ODENet instantiation as an argument. I was wondering how you are able to then provide the ODEBlock with the eval_times for the flux data in the forward function, as the ODENet.forward() function does not take in eval_times as an argument.

So I've probably demonstrated a couple misunderstandings. For one, is it just going to be flawed methodology to try and chunk up my data according to individual astronomical objects? ie: should I just train one huge ODE for the entire time series? (this seems wrong if I ignore the object id and other data, since the fluxes of one object aren't related to those of another).

TL;DR: I'm not exactly sure how to provide the solver eval_times (from a DataLoader) in ODENet's forward function / training.Trainer class.

Thanks again.

anandijain commented 5 years ago

One last thought I had for how I learn the function for flux/time (aside from providing odeint with the times from my dataframe/loader): Should my dataloader's Y value actually just be the same flux values as my X? (essentially using the ode to encode the data).

My main task (at least for the coming couple days) is just to have the solver learn to fit a single light curve and then allow me to plot/evaluate what it thinks the flux values are in between data points. (or ideally just plot the continuous line/curve.

EmilienDupont commented 5 years ago

Hi! Thanks for your question. I'm not sure I have understood everything correctly, but I will do my best to answer 😄

  1. First I am not 100% sure what you are given and what you are trying to predict. Are you given a time series of flux data and would like to predict which type of light curve the flux corresponds to? Or are you trying to model the evolution of the flux data itself? These seem like two separate problems.

  2. In order to call the ODENet.forward() method with eval_times, you could change the code to add an argument eval_times to the method and then replace features = self.odeblock(x) with features_time = self.odeblock(x, eval_times=eval_times). This will then return a set of features for each time step as opposed to just the final one.

  3. Your input is a (352, 2) tensor. Is the first column timestamps and the second column flux values? If you are interested in learning the ODE that governs the flux evolution and if this ODE only depends on time and flux, i.e. dflux/dt = f(flux, t), then you should be able to learn this f with the Neural ODE framework. Your input would then simply be flux(t=0) and then your targets would be the flux(t=t_i) values for all the t_i in your data.

Hope this makes sense and let me know if you have any more questions! And sorry if I misunderstood some of your questions too :)