-
Notifications
You must be signed in to change notification settings - Fork 101
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
Add Bayesian differential equations tutorial #68
Conversation
And just to show off, SDEs and DDEs are in there too, so yay Turing is the first! @Vaibhavdixit02 is going to take it from here.
Check out this pull request on Review Jupyter notebook visual diffs & provide feedback on notebooks. Powered by ReviewNB |
100% rad, thanks @ChrisRackauckas and @Vaibhavdixit02! Looking forward to this. |
You should make sure to use |
Finish up diffeq turing tutorial
View / edit / reply to this conversation on ReviewNB devmotion commented on 2020-05-22T16:56:04Z I'd suggest to replace
ChrisRackauckas commented on 2020-05-22T17:00:41Z Yup good ideas. Vaibhavdixit02 commented on 2020-05-23T08:39:13Z It fails here with " Vaibhavdixit02 commented on 2020-05-23T08:47:32Z
ChrisRackauckas commented on 2020-05-23T08:49:37Z yeah, adjoints need arrays, so it's best to just use arrays for now. devmotion commented on 2020-05-23T09:54:06Z Yeah, I was wondering if that would be a problem. Would be nice to support tuples but I guess then it's best to use arrays for now. |
View / edit / reply to this conversation on ReviewNB devmotion commented on 2020-05-22T16:56:05Z Same here. |
View / edit / reply to this conversation on ReviewNB devmotion commented on 2020-05-22T16:56:05Z Same here. |
View / edit / reply to this conversation on ReviewNB devmotion commented on 2020-05-22T16:56:06Z Same here. |
View / edit / reply to this conversation on ReviewNB devmotion commented on 2020-05-22T16:56:06Z Remove the multiplication signs and unneeded brackets and write ChrisRackauckas commented on 2020-05-22T17:00:12Z Agreed Vaibhavdixit02 commented on 2020-05-23T08:51:05Z introduce history function I didn't get this completely, can you write out what you mean
The current version is
$h(\alpha,\beta,\gamma,\delta,t) = [1,1] $ ChrisRackauckas commented on 2020-05-23T08:53:35Z "h" isn't a thing. "h" is actually just the history here. In psuedo-tex, it's
dxdt = \alpha x(t-1) - \beta x y
There's no reason to ever write "h" in the LaTeX |
View / edit / reply to this conversation on ReviewNB devmotion commented on 2020-05-22T16:56:07Z Same here. Also are you sure that everything works as expected, since (some time ago) optimization of DDEs with ForwardDiff was broken? https://github.com/SciML/DelayDiffEq.jl/issues/133 ChrisRackauckas commented on 2020-05-22T17:00:02Z https://github.com/SciML/DelayDiffEq.jl/blob/master/test/interface/ad.jl passes. I think #133 only is for the case of estimating the delay length itself, but if that's fixed we're good. If it's not fixed, it seems like it works but we're missing a test on it and IIRC that's why we're keeping it open. I've also fixed a lot of things on estimating delays for Pumas, so I wouldn't be surprised if even what we think might not be working is now working. devmotion commented on 2020-05-22T17:51:47Z The tests pass since they are marked as broken 😄 But they test estimation of the delay length as well, so maybe we're good without it. Should add some tests without delay length estimation to make sure that's the case. ChrisRackauckas commented on 2020-05-23T10:03:18Z FWIW, training in DiffEqFlux seems to work, so I don't know what's going on in those AD tests but we should definitely get it figured out. |
https://github.com/SciML/DelayDiffEq.jl/blob/master/test/interface/ad.jl passes. I think #133 only is for the case of estimating the delay length itself, but if that's fixed we're good. If it's not fixed, it seems like it works but we're missing a test on it and IIRC that's why we're keeping it open. I've also fixed a lot of things on estimating delays for Pumas, so I wouldn't be surprised if even what we think might not be working is now working. View entire conversation on ReviewNB |
Agreed View entire conversation on ReviewNB |
Yup good ideas. View entire conversation on ReviewNB |
The tests pass since they are marked as broken 😄 But they test estimation of the delay length as well, so maybe we're good without it. Should add some tests without delay length estimation to make sure that's the case. View entire conversation on ReviewNB |
It fails here with " View entire conversation on ReviewNB |
View entire conversation on ReviewNB |
yeah, adjoints need arrays, so it's best to just use arrays for now. View entire conversation on ReviewNB |
introduce history function I didn't get this completely, can you write out what you mean
The current version is
$h(\alpha,\beta,\gamma,\delta,t) = [1,1] $ View entire conversation on ReviewNB |
"h" isn't a thing. "h" is actually just the history here. In psuedo-tex, it's
dxdt = \alpha x(t-1) - \beta x y
There's no reason to ever write "h" in the LaTeX View entire conversation on ReviewNB |
Yeah, I was wondering if that would be a problem. Would be nice to support tuples but I guess then it's best to use arrays for now. View entire conversation on ReviewNB |
FWIW, training in DiffEqFlux seems to work, so I don't know what's going on in those AD tests but we should definitely get it figured out. View entire conversation on ReviewNB |
Address review comments
View / edit / reply to this conversation on ReviewNB ChrisRackauckas commented on 2020-05-23T13:58:16Z no * |
View / edit / reply to this conversation on ReviewNB ChrisRackauckas commented on 2020-05-23T14:06:13Z The sensitivity equation didn't show. |
View / edit / reply to this conversation on ReviewNB ChrisRackauckas commented on 2020-05-23T14:06:13Z This fit seems far off: lower the tolerances? Vaibhavdixit02 commented on 2020-05-23T14:29:06Z This is pretty slow, 14 minutes for 100 iterations. It needs to run for much more but it's so slow?
devmotion commented on 2020-05-23T14:33:12Z Shouldn't it be just devmotion commented on 2020-05-23T14:37:54Z You should be able to gain a speed up by using multiple threads and writing ChrisRackauckas commented on 2020-05-23T14:38:09Z yes ChrisRackauckas commented on 2020-05-23T14:39:46Z it should be σ. ReverseDiff should be much slower than ForwardDiff through the solver, but not that much slower? Are you on master? Add a print statement to make sure it's using the InterpolatingAdjoint ChrisRackauckas commented on 2020-05-23T14:40:02Z Recent DiffEqBase release added this (mostly for this tutorial) devmotion commented on 2020-05-23T14:40:14Z BTW you don't use |
View / edit / reply to this conversation on ReviewNB ChrisRackauckas commented on 2020-05-23T14:06:14Z This fit is off too Vaibhavdixit02 commented on 2020-05-23T14:29:26Z 18 minutes for 100 iterations.. |
View / edit / reply to this conversation on ReviewNB ChrisRackauckas commented on 2020-05-23T14:06:15Z The * here again. Also, I don't know where the d(x) convention is from, but people usually just do dx and dt here. |
Recent DiffEqBase release added this (mostly for this tutorial) View entire conversation on ReviewNB |
BTW you don't use View entire conversation on ReviewNB |
View / edit / reply to this conversation on ReviewNB ChrisRackauckas commented on 2020-05-24T19:28:15Z dW_1 and dW_2 |
View / edit / reply to this conversation on ReviewNB ChrisRackauckas commented on 2020-05-24T19:28:15Z Can this be ran longer? It'll take a bit, but it's right. Vaibhavdixit02 commented on 2020-05-24T19:31:14Z 1000? Yeah, I'll leave it overnight now :) devmotion commented on 2020-05-25T22:15:23Z A quick inspection reveals many type inference problems: varinfo = Turing.VarInfo(model) spl = Turing.SampleFromPrior()
In particular, the type of But yeah, also here the problem seems to be that even if you manage to sample the chains are completely stuck. Did it improve at all with more samples? devmotion commented on 2020-05-25T22:58:08Z BTW I tried Gibbs sampling with MH
and got Sampling: 100%|█████████████████████████████████████████| Time: 0:05:24 Object of type Chains, with data of type 1000×8×1 Array{Float64,3} which is not completely great but somewhat close to the true parameter values at least.
|
View / edit / reply to this conversation on ReviewNB ChrisRackauckas commented on 2020-05-24T19:28:16Z let's just remove DDEs until the AD bug is fixed. Vaibhavdixit02 commented on 2020-05-24T19:33:21Z I hadn't paid attention to the estimate lol
|
1000? Yeah, I'll leave it overnight now :) View entire conversation on ReviewNB |
I hadn't paid attention to the estimate lol
View entire conversation on ReviewNB |
View / edit / reply to this conversation on ReviewNB ChrisRackauckas commented on 2020-05-25T19:15:07Z what happened here? devmotion commented on 2020-05-25T21:53:06Z I was wondering the same... It seems the chain gets stuck since all proposals are rejected (basically all samples after iteration 8000 it seems). Vaibhavdixit02 commented on 2020-05-26T05:42:00Z I don't know at this point. It happened with the Turing update to v0.13.0.
ChrisRackauckas commented on 2020-05-26T13:39:46Z This is worth having someone dig into then... that doesn't look good at all. |
Are there plots of the coefficients, chains, and the fits to go along with the results? |
I was wondering the same... It seems the chain gets stuck since all proposals are rejected (basically all samples after iteration 8000 it seems). View entire conversation on ReviewNB |
A quick inspection reveals many type inference problems: varinfo = Turing.VarInfo(model) spl = Turing.SampleFromPrior()
In particular, the type of But yeah, also here the problem seems to be that even if you manage to sample that the chains are completely stuck. Did it improve at all with more samples? View entire conversation on ReviewNB |
BTW I tried Gibbs sampling with MH
and got Sampling: 100%|█████████████████████████████████████████| Time: 0:05:24 Object of type Chains, with data of type 1000×8×1 Array{Float64,3} which is not completely great but somewhat close to the true parameter values at least.
View entire conversation on ReviewNB |
I don't know at this point. It happened with the Turing update to v0.13.0.
View entire conversation on ReviewNB |
View / edit / reply to this conversation on ReviewNB Vaibhavdixit02 commented on 2020-05-26T05:55:11Z >Did it improve at all with more samples?
Yeah, with 500 it is better. ChrisRackauckas commented on 2020-05-26T13:38:59Z ehh good enough to ship IMO. Just mention that SDEs are a lot more computationally intensive and so for very good estimates one should run it with more trajectories and more samples ChrisRackauckas commented on 2020-05-26T13:40:22Z Or, how about doing an MAP method and then starting the chains at the MAP? Vaibhavdixit02 commented on 2020-05-26T17:21:58Z MAP doesn't give me an answer, errors out after a lot of instability warnings. |
ehh good enough to ship IMO. Just mention that SDEs are a lot more computationally intensive and so for very good estimates one should run it with more trajectories and more samples View entire conversation on ReviewNB |
This is worth having someone dig into then... that doesn't look good at all. View entire conversation on ReviewNB |
Or, how about doing an MAP method and then starting the chains at the MAP? View entire conversation on ReviewNB |
MAP doesn't give me an answer, errors out after a lot of instability warnings. View entire conversation on ReviewNB |
Unrelated to the issues discussed above, when playing around with the draft yesterday I noticed that Manifest.toml should be updated and completed. |
View / edit / reply to this conversation on ReviewNB Vaibhavdixit02 commented on 2020-05-27T19:07:58Z There is something going on with the step size, for other values of step size (I get 0.0125, 0.05, 0.02) than 0.025 the estimates are far off and give a lot of
with 0.025 it works well and the estimates are accurate.
|
Thanks @Vaibhavdixit02 for taking it over the finish line. I think it can get continually improved, and the Turing developers might want to look at that issue with the stepsizes, but IMO it's good enough to release. |
I'm happy to merge -- anyone have further comments? If not, I'll plan on merging tomorrow morning (PST) and getting everything ready to go to get this on turing.ml. Thanks, you guys! Spectacular work. |
And just to show off, SDEs and DDEs are in there too, so yay Turing is the first!
@Vaibhavdixit02 is going to take it from here.