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

implement mohamed's solution (#12#issuecomment-451416440) #13

Closed
wants to merge 1 commit into from

Conversation

xukai92
Copy link
Member

@xukai92 xukai92 commented Jan 11, 2019

Resolving #12

@xukai92 xukai92 requested a review from mohamed82008 January 11, 2019 02:36
@xukai92
Copy link
Member Author

xukai92 commented Jan 11, 2019

My editor removed some empty spaces automatically. But I guess it's fine.

Copy link
Member

@mohamed82008 mohamed82008 left a comment

Choose a reason for hiding this comment

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

These changes look good to me. Also if you manage to find a reproducible example (with a certain seed) that generates the error in Turing's Travis (or hits the max with this PR), please file an issue so I can take a closer look.

Also, are these the only logs we need to worry about?

@yebai
Copy link
Member

yebai commented Jan 11, 2019

@xukai92 could the same fix be applied to similar transforms, e.g. Beta and Gamma? It seems these transforms are occasionally causing tests broken in TuringLang/Turing.jl#621

@@ -276,11 +276,11 @@ function logpdf_with_trans(

sum_tmp = zero(eltype(x))
z = x[1]
lp += log(z + ϵ) + log(one(T) - z + ϵ)
lp += log(max(0, z + ϵ)) + log(max(0, one(T) - z + ϵ))
Copy link
Member

Choose a reason for hiding this comment

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

perhaps we can overload log(x)=log(max(0, x))? This would fix all uses of log's, e.g. those in univariate distributions with lower / upper bounds.

Copy link
Member

Choose a reason for hiding this comment

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

May be but that would give a stack overflow. _log(x) = log(max(0, x)) would do, replacing all uses of log with _log.

Copy link
Member Author

Choose a reason for hiding this comment

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

Or we'd name it something like logsafe so that it's more informative?

@yebai
Copy link
Member

yebai commented Jan 15, 2019

Closed in favour of #14

@yebai yebai closed this Jan 15, 2019
@yebai yebai deleted the kx/simplex-trans-stability branch September 24, 2019 19:54
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.

3 participants