-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MOGPR performance analysis & improvements #75
Comments
Thanks, I will share this with our experts to see if we can push it to our agenda and take a look. Will keep you posted |
We looked at the code for MOGPR. We prepared a snippet for running and debugging the core functionality. Our first impression was that the code could be written in a bit more pythonic way, however, after running the profiler we noticed that the majority of time is spent at training, so we're confirming findings from others. Making the code more pythonic wouldn't make a dent. The code was run on the test dataset used in the notebook. Here are the results: Total time spent in the optimization (training) part is ~1000 s, which is 90% of total time and ~0.16 s per pixel in average (quite slow). In order to run things as they are, one would need to optimize to the order of the 1 ms per pixel level to make things fast enough to be useful and convenient. We had a quick look at the While we're on the topic. I think there is a bigger issue here. This method requires training the MOGPR model for each pixel. This is the main problem of the slowness of this approach. It seems to me that such an approach is also inherently suboptimal, or even wrong. One of the main issues (putting slowness aside) is probably bad performance when the pixel data is bad. Not having NDVI due to all obs. being cloudy means that the training for this particular pixel will be sh*t/fail, and the output will be useless, while there exist plenty of other pixels with similar phenology and plenty of data to be used for training and creating a useful model. I don't believe the Example use case: This requires quite some change in the codebase, so I'm not sure how to proceed (@JanssenBrm @jdries @JochemV) We will still try to make use of the |
Hi @mlubej ! Thanks for the thorough study. Mogpr models do not rely on samples, but on hyperparameters regarding the input signals and the relation between them. Most of the mogpr processing time is spent on the tuning/optimization of these hyperparameters(lengthscale, variance , B.W and B.kappa). Let´s say that for the most demanding setting that we have tried, with 3 input signals(NDVI, RVI_ASC, RVI_DESC) and 4 years, we have the following, It takes a running time of ~39 seconds(this processing is done locally on my personal computer) When I have some results I´ll post them here. |
@msalinero the results I posted above were done for a single variable (is this then only interpolation?) and for a single year. Are the numbers in your case derived for a single pixel timeseries? If yes, then I imagine even 4.3 s per pixels is still quite slow, but I agree that what you suggest with fixing hyperparameters for some specific phenology is a good approach. We also discussed about the possibility to randomly sample timeseries from the AOI and run unsupervised clustering in order to obtain some generic and representative timeseries for the most common areas. Of course, in case of crops it might make even more sense to do supervised clustering. As you say, even doing this just for fixing the hyperparameters might already prove to be beneficial. Would it be possible/applicable to train the full model for such representative timeseries, or would such an approach make sense only for the hyperparameter tuning? |
My results are for one pixel or, better said, for the mean of the rye patch showed in
From my point of view, this approach would only make sense for the hyperparameter tuning |
@jdries @msalinero together with @veseln we tried the almost drop-in replacement of The code difference wasn't big so there is little chance of us f*****g up something, but in the end the new code ran 4x slower. I can't imagine why Our suggestion would be to stick with the @jdries a question for you: Imagine the use case where one would like to fuse radar and optical data using MOGPR. In order to successfully tune the MOGPR hyperparameters the user would prepare a few key time-series, e.g. for each of the crops they are interested in. For each of these time-series the tuning would be run, and then the constrained process would be applied on the pixel- or parcel-level timeseries of the same crop. The question here is how to imagine the implementation of such a process? I don't have a clear vision of how the process above should look like in the scope of openeo/fusets, at least in the sense of it being a single pipeline of user-defined functions. It seems to me there are steps between where the pixel/object scope changes, and I find it hard to imagine how to go about this (possibly due to my lack of in-depth knowledge of the codebase). Please advise. From Sinergise point-of-view, the easiest way to figure out if there is value in fused timeseries is doing object based approach and quantifying what value it brings to area monitoring, so this is the direction in which we would like to go in, similar to the example described above. @JochemV @msalinero would such an approach also fit your use case, or do you have some other approach planned? |
Nice overview! Maybe we can also have a feature that samples input pixels, and computes the error of the per-pixel model versus a selected global model. This would then allow a user to evaluate easily if the global model is applicable to the dataset at hand? Another idea would be if we could determine a set of cheaper timeseries 'features' that have a high correlation with the hyper parameters, allowing us to 'guess' the right model based on cheaper inputs rather than an expensive per-pixel training? @msalinero are there sets of hyperparameters that have been determined before that we can integrate in the library? And do we know what basic information is needed to a given global model? How input specific are these global parameters? |
@jdries Happy that you are asking these questions, because my efforts lastly were going in that direction. Following the logic of the paper from our colleague Santiago, I´m trying to get the mean of the MOGPR hyperparameters of several parcels. Then, I´ll try to use these obtained values and see how they behave. From my knowledge, there are not already generated hyperparameters for each crop type. The ones used in the paper are for LAI and single input GPR. Also, from what we have seen in previous studies, they depend greatly in the variable at hand. Better said, you will not get good results using LAI hyperparameters in a NDVI timeseries. If we can go for a global crop model, as suggested in the paper, and get promising results, this would greatly simplify the task. Later, of course, we can even play a bit more and see how this model behaves with other land covers, like forest, etc. |
Thank you @msalinero for this article. We will follow this procedure where we use averaged HPO for meadow areas. One of the differences is that in our use case we have 1 year of data, so we will have to focus more on time-series where observations are without larger gaps for the training step, but this shouldn't be such a problem. Do you suggest to go with the Matern 3/2 kernel, similarly as it's implemented in https://github.com/Open-EO/FuseTS/blob/main/src/fusets/mogpr.py#L360 ? |
@mlubej Glad that the paper is of help! I prefer the Matern 3/2 kernel over the standard RBF kernel as the Matern kernel is less smooth thus more sensible to changes. For me it worked better most of the time. About only having 1 year of data, maybe you can "concatenate" this same year several times and then induce gaps artificially. |
As discussed during the enhancement review: we could already improve the usage experience by clearly documenting the different limitations of the MOGPR implementation within FuseTS. |
The current MOGPR implementation can be quite heavy, especially when computing/training a new model per timeseries, but also the basic inference.
The main work for this is being done in the GPy library, which also has a successor based on Tensorflow (GPFlow).
Hence the most obvious thing to try first, is porting to this tensorflow based library:
https://gpflow.github.io/GPflow/develop/notebooks/advanced/multioutput.html
Current GPy model training:
https://github.com/Open-EO/FuseTS/blob/main/src/fusets/mogpr.py#L364
And inference:
https://github.com/Open-EO/FuseTS/blob/main/src/fusets/mogpr.py#L389
Note that there's also the idea of avoiding to retrain the model per pixel, which is a separate issue!
The text was updated successfully, but these errors were encountered: