Skip to content
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

Fix HMC in Gibbs issue with dynamic models #1217

Merged
merged 6 commits into from
Apr 13, 2020
Merged

Fix HMC in Gibbs issue with dynamic models #1217

merged 6 commits into from
Apr 13, 2020

Conversation

mohamed82008
Copy link
Member

This PR fixes #1095 by making sure the position in the HMC PhasePoint is of the right length and value.

CC: @xukai92 @trappmartin

@codecov
Copy link

codecov bot commented Apr 13, 2020

Codecov Report

Merging #1217 into master will increase coverage by 0.31%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1217      +/-   ##
==========================================
+ Coverage   65.59%   65.91%   +0.31%     
==========================================
  Files          25       25              
  Lines        1279     1282       +3     
==========================================
+ Hits          839      845       +6     
+ Misses        440      437       -3     
Impacted Files Coverage Δ
src/inference/hmc.jl 88.13% <100.00%> (+0.30%) ⬆️
src/inference/Inference.jl 78.57% <0.00%> (+1.02%) ⬆️
src/inference/AdvancedSMC.jl 96.96% <0.00%> (+1.51%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5440b3f...c94e928. Read the comment docs.

src/inference/hmc.jl Outdated Show resolved Hide resolved
@trappmartin
Copy link
Member

Cool, thanks!

@xukai92 xukai92 self-requested a review April 13, 2020 14:20
@trappmartin trappmartin merged commit 57c5ef9 into master Apr 13, 2020
@delete-merged-branch delete-merged-branch bot deleted the mt/fix_1095 branch April 13, 2020 15:00
∂logπ∂θ = gen_∂logπ∂θ(spl.state.vi, spl, model)
logπ = gen_logπ(spl.state.vi, spl, model)
spl.state.h = AHMC.Hamiltonian(metric, logπ, ∂logπ∂θ)
resize!(spl.state.z.θ, length(θ_old))
Copy link
Member

@yebai yebai Apr 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is worth noting that the vanilla HMC with identity mass matrix and pre-specified leapfrog step-size might be the only sensible HMC sampler for dynamic models for now, since the adaption schedules for step-size and mass matrix are not guaranteed to work well when the static dimensionality condition no longer holds.

@trappmartin @mohamed82008 @xukai92

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trappmartin Maybe add a warning for this in the Infinite Mixture Model example?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'll open a PR for this.

phipsgabler pushed a commit to phipsgabler/Turing.jl that referenced this pull request May 12, 2020
* fix TuringLang#1095

* add test

* fix bug

* test PG and MH

* fix tests

* avoid duplicate line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dynamic models seem to break
4 participants