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 broken case when variables are multi-dimensional and add tests for AdvancedHMC extension and inference #89

Merged
merged 23 commits into from
Sep 17, 2023

Conversation

sunxd3
Copy link
Member

@sunxd3 sunxd3 commented Sep 13, 2023

Fix #71.

@sunxd3 sunxd3 requested a review from yebai September 13, 2023 09:58
test/inference.jl Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.18% ⚠️

Comparison is base (35661f6) 72.16% compared to head (6a37dfd) 71.98%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #89      +/-   ##
==========================================
- Coverage   72.16%   71.98%   -0.18%     
==========================================
  Files          16       16              
  Lines        1631     1635       +4     
==========================================
  Hits         1177     1177              
- Misses        454      458       +4     
Files Changed Coverage Δ
src/BUGSExamples/BUGSExamples.jl 20.00% <0.00%> (-80.00%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 14, 2023

Pull Request Test Coverage Report for Build 6213349923

  • 0 of 4 (0.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.2%) to 71.988%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/BUGSExamples/BUGSExamples.jl 0 4 0.0%
Totals Coverage Status
Change from base Build 6213090706: -0.2%
Covered Lines: 1177
Relevant Lines: 1635

💛 - Coveralls

@sunxd3
Copy link
Member Author

sunxd3 commented Sep 14, 2023

@yebai another look?

test/inference.jl Outdated Show resolved Hide resolved
Comment on lines 31 to 33
t = ts[1]
tstat = merge((; lp=t.z.ℓπ.value), stat(t))
tstat = merge((; lp=t.z.ℓπ.value), AdvancedHMC.stat(t))
tstat_names = collect(keys(tstat))
Copy link
Member

Choose a reason for hiding this comment

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

It appears these lines are the only AHMC specific code.

If so, can we improve this module by abstracting out the AHMC specific code into a lightweight separate extension? We can then convert this module into a generic JuliaBUGSMCMCChainsExt which can be shared by other samplers like AMH?

@sunxd3
Copy link
Member Author

sunxd3 commented Sep 17, 2023

@yebai I moved the reference results to BUGSExamples, e.g.,

reference_results=(
alpha0=(mean=-0.5499, std=0.1965),
alpha1=(mean=0.08902, std=0.3124),
alpha12=(mean=-0.841, std=0.4372),
alpha2=(mean=1.356, std=0.2772),
sigma=(mean=0.2922, std=0.1467),
),
)

Also created a function at
function has_ground_truth(m::Symbol)
if m in union(keys(VOLUME_I), keys(VOLUME_II))
return haskey(getfield(BUGSExamples, m), :reference_results)
else
return false
end
end

Maybe something like

has_ground_truth(::Val{:seeds}) = true

# call
has_ground_truth(Val(:seeds))

is better?

For now, I'll merge this PR, we can improve in the future.

@sunxd3 sunxd3 merged commit 1f5dd43 into master Sep 17, 2023
11 of 13 checks passed
@sunxd3 sunxd3 deleted the sunxd/ahmc branch September 17, 2023 12:04
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.

Add logdensity_and_gradient and/or few cycles of HMC sampling to the tests
2 participants