Skip to content

Modify compound steps notebook #141

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

Merged
merged 4 commits into from
Apr 6, 2021
Merged

Modify compound steps notebook #141

merged 4 commits into from
Apr 6, 2021

Conversation

mjhajharia
Copy link
Member

This PR addresses issue #113

  • Adds Arviz Inference Data
  • Uses Coords and Dims
  • Adds an arviz plot of sample stats to understand them for compound steps, as it is not explicitly explained anywhere else
  • Info on sample stats variables common between samplers, noticed this on sampler stats #95 but this seems to be a more relevant place for this explanation

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@mjhajharia mjhajharia closed this Apr 5, 2021
@mjhajharia mjhajharia reopened this Apr 5, 2021
@mjhajharia mjhajharia closed this Apr 5, 2021
@mjhajharia mjhajharia reopened this Apr 5, 2021
@mjhajharia
Copy link
Member Author

finally fixed this git rebase thing oof, excuse the bad open/close history ;-;

@mjhajharia
Copy link
Member Author

@OriolAbril I considered explaining the two variable part of compound sampling over here, and just mentioning it along with showing the outliers in the sample_stats notebook. Does that make sense?

@@ -12,10 +12,24 @@
"# Compound Steps in Sampling\n",
Copy link
Member

@OriolAbril OriolAbril Apr 5, 2021

Choose a reason for hiding this comment

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

I would keep the original code because it has 2 advantages. 1st is that it shows how one can sample the same model as many times as they want with different samplers, iterations or whatever. 2nd is that this is an actual model with observed variables, the mu1, mu2 example only samples from free variables, it doen't sample from a posterior. We can still use coords and dims by using idata_kwargs (in which case we don't need to use coords when defining the model)


Reply via ReviewNB

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried keeping the original code and for some reason that didn't give me two values for "accept", so I was somewhat confused

Copy link
Member

Choose a reason for hiding this comment

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

I think the original code was not sampling with the custom steps defined, only printing them to show which order they define, so trace probably referred to the trace from the other model, sampled combining nuts and metropolis instead of combining two metropolis.

Copy link
Member Author

Choose a reason for hiding this comment

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

in the latest commit, i sampled after defining steps

Copy link
Member

Choose a reason for hiding this comment

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

Took a look at the code, it's probably due to BinaryGibbsMetropolis not having accept unline BinaryMetropolis, so there is no repeated name on which to concatenate the accept stat

Copy link
Member Author

@mjhajharia mjhajharia Apr 5, 2021

Choose a reason for hiding this comment

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

so I should go for binarymetropolis and metropolis instead of binarygibbs and metropolis right? (because it feels like explaining this is an imp point(?))

Copy link
Member

Choose a reason for hiding this comment

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

I would use BinaryMetropolis. I am not sure how used are compound methods, but all the order and other explanations done with BinaryGibbsMetropolis will still be relevant, we will only be adding the repreated stats component

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, it worked like a charm, I'll push the latest commit, I think it looks almost ready now

@mjhajharia
Copy link
Member Author

mjhajharia commented Apr 5, 2021

@OriolAbril I've made changes except the last two comments, it'd be great if you could have a look and tell me if i missed something, was idata_kwargs supposed to be given once, or during every consecutive event of sampling? (else I'll get back to it tomo and go over again) - check latest commit for context.

@mjhajharia mjhajharia requested a review from OriolAbril April 5, 2021 18:29
@@ -12,10 +12,11 @@
"# Compound Steps in Sampling\n",
Copy link
Member

Choose a reason for hiding this comment

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

I would add that comment as a markdown cell and not print the whole dataarray


Reply via ReviewNB

Copy link
Member Author

Choose a reason for hiding this comment

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

does printing one chain work?

Copy link
Member Author

Choose a reason for hiding this comment

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

trace1.sample_stats["accept"].sel(chain=1).values

I'm going for this because it helps actually notice the two sampler step accept thing and this doesnt take up much space

@mjhajharia
Copy link
Member Author

@OriolAbril thanks for the suggestions! everything's done

@mjhajharia mjhajharia changed the title Modify compound steps notebook[WIP] Modify compound steps notebook Apr 5, 2021
@mjhajharia mjhajharia marked this pull request as ready for review April 5, 2021 19:33
@OriolAbril OriolAbril merged commit d9b16d8 into pymc-devs:main Apr 6, 2021
@mjhajharia mjhajharia deleted the steps branch April 6, 2021 18:50
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.

2 participants