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

Simplify tests and do not use eval #88

Merged
merged 3 commits into from
Jun 23, 2020
Merged

Conversation

devmotion
Copy link
Member

@devmotion devmotion commented Jun 22, 2020

This PR is basically a slightly modified copy of TuringLang/Bijectors.jl#116. Instead of FiniteDiff it uses FiniteDifferences (since DistributionsAD uses it already), and I added some additional transformations to ensure that parameters and samples are always in the correct domains.

This PR is based on #87 since it seemed weird to keep the special non-randomized tests for Dirichlet that couldn't capture the bug in #86.

@devmotion
Copy link
Member Author

Zygote tests passed (after 30 minutes instead of 1h 48min on master 😃), which indicates that #87 is fine (Zygote tests there are still running).

@torfjelde
Copy link
Member

So this looks all good to me, but that's because I already saw the same thing earlier 😅 Should I just accept it or should maybe someone else also have a look, just to be sure?

@devmotion
Copy link
Member Author

I requested a review from @mohamed82008 as well since I assume he implemented the current test setup.

@yebai
Copy link
Member

yebai commented Jun 23, 2020

@mohamed82008

@yebai yebai merged commit acd5425 into TuringLang:master Jun 23, 2020
@yebai
Copy link
Member

yebai commented Jun 23, 2020

thanks, @devmotion -- nice improvements!

@devmotion devmotion deleted the eval_fix branch June 23, 2020 19:29
@mohamed82008
Copy link
Member

Sorry guys I was moving houses and had internet issues. Had a quick scan and looks good though.

end

if isempty(θ)
# In this case we can only test the gradient with respect to `x`
Copy link
Member

Choose a reason for hiding this comment

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

We should test wrt to x only even if theta is not empty.

Copy link
Member

Choose a reason for hiding this comment

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

And we should check if the support is continuous first.

Copy link
Member Author

Choose a reason for hiding this comment

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

The logic is just copied from the previous implementation. There we test wrt x if theta is empty and don't check if the support is continuous (see e.g. https://github.com/TuringLang/DistributionsAD.jl/blob/master/test/test_utils.jl#L126 - somehow I forgot to delete the file...). I guess it's OK to not check if the support is continuous, since otherwise we couldn't test any derivatives at all and the DistSpec would not be useful. Additionally, both in the old and new implementation we test wrt x if theta is not empty and the support is continuous.

Copy link
Member

Choose a reason for hiding this comment

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

Even if the old implementation didn't test wrt x only with a non-empty theta, we still should. This is useful for prior distributions in Turing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm I can't follow, why would we want to remove tests? As long as tests pass in a reasonable amount of time (which they do with the new implementation), it should always be better to perform more tests, shouldn't it?

Copy link
Member

Choose a reason for hiding this comment

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

Yes I am suggesting performing more tests :) Currently I don't think we test wrt to x and only x when theta is not empty.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah I see, somehow I didn't get it and assumed you would want to remove some of the existing tests 😆

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.

None yet

4 participants