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
Implement Iterated EKF and Iterated EKS #135
Conversation
Hi, It's worth noting your implementation will incur a very large memory consumption when taking gradients of the log-likelihood, see https://arxiv.org/abs/2207.00426, Section VII. This can be avoided by remarking that the result of the posterior linearisation verifies a fixed point equation. This extends directly to IEKF, where instead of the full trajectory obeying a fixed point, it will simply be the marginal states. |
Thanks @AdrienCorenflos! Out of curiosity, have you encountered numerical instability with the custom vjp for |
Well, not really no. I think that the gradient fixed point has exactly the same convergence properties as the forward one (because they have the same Lipschitz constants). Technically, I think one should probably use line search or similar just like you would do for the IEKS but I don't think there are empirical or theoretical studies on the topic |
Interesting, that’s good to hear. I’ll have to dig up that old CAVI example. Maybe it just needed a smaller convergence threshold, or maybe it was something more fundamental about that setup. I know IFT requires certain properties of the fixed point, and it could be that they weren’t satisfied in that problem. Anyway, separate issue! |
Although, I'm saying this, but for param estimation, the algo may diverge fairly easily if your initial trajectory is not "good enough". We had this problem with @Fatemeh-Yaghoobi in our paper. We fixed it by essentially using the initial trajectory that would have corresponded to just inverting the observation model by ignoring the observation noise and dynamics and it made everything much more robust. Can't remember if we mentioned this implementation detail in the paper. See |
Ugh, initialization was the bane of my existence with SLDS models. I ended up doing the same thing to initialize continuous state estimates. We’ve ignored that issue so far in this repo, but we’ll need to confront it sooner or later. |
Also, some recent work that we didn't cite ('cause I read it after the we uploaded the paper) is concerned with describing very generally how one should implement gradient of fixed points https://arxiv.org/abs/2105.15183 if you are into this kind of thing. |
We might want to keep Peter's current straightforward implementation as a readable reference, before adding your fixed point version. |
Description
iterated_extended_kalman_filter()
inekf/inference.py
. Note that the parameternum_iter
is the number of re-linearizations around the posterior, which means that the regular EKF would correspond tonum_iter=0
.extended_kalman_smoother()
to take in an optionalfiltered_posterior
parameter which the smoother uses as the filtered posterior in carrying out smoothing. This is useful for IEKS.iterated_extended_kalman_smoother()
inekf/inference.py
.Figure
Issue
#139