You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the intent is for TensorFlow to be a general purpose computational tool for machine learning there should be more support for special functions (i.e. the functions in scipy.special). In particular, functions occurring in probability distributions such as the gamma(ln) are quite central to probabilistic machine learning.
I was just thinking of implementing some Bayesian learning on TensorFlow and realised that I would need the Gamma and also in particular LogGamma (this is just the log of the Gamma function computed directly). These are absolutely essential for many distributions (Beta, Dirichlet). I would love to help to add them, however could you please provide some small guidance on where to start? I see there are many levels of op implementation, description, Python wrapping etc. Thanks
Yeah; this has been implemented and should make it into the next upstream release. I've added lgamma to Eigen (both ours & upstream) and added an lgamma unary op.
Digamma should also make its way in, in the next 2 weeks.
@ebrevdo is it possible for me to pull the lgamma implementation from your repo? I can't see it in your profile, perhaps it's internal at your company, and I can't just pull changes from it? I really need lgamma soon, can't wait ;)
@akuz I've been using a hack where you just define a series expansion within the TF graph. It's not pretty and I don't guarantee accuracy, but if you really can't wait for proper support it might be worth a try:
def gammaln(x):
# fast approximate gammaln from paul mineiro
# http://www.machinedlearnings.com/2011/06/faster-lda.html
logterm = tf.log (x * (1.0 + x) * (2.0 + x))
xp3 = 3.0 + x
return -2.081061466 - x + 0.0833333 / xp3 - logterm + (2.5 + x) * tf.log (xp3)
Sorry to dig this up again, but are there any plans to incorporate the polygamma function (1) in the near future? Anything using a Dirichlet / Beta prior distribution will utilise the digamma function, for which the gradient is the polygamma.
Sorry to dig this up again, but are there any plans to incorporate the
polygamma function (1) in the near future? Anything using a Dirichlet /
Beta prior distribution will utilise the digamma function, for which the
gradient is the polygamma.
—
You are receiving this because you modified the open/close state.
Reply to this email directly or view it on GitHub: #291 (comment)
That's true - sorry, should have been more specific. The digamma/polygamma come up when computing expectations and KL divergences for dirichlet distributions. Is this general enough to warrant a place in Tensorflow, or should I be independently implementing it (or contributing it)?
it is worthwhile to add trigamma or polygamma from cephes. you will have to add it to Eigen first, and verify CUDA support works. see bitbucket.org/eigen/eigen/ and specifically my PRs adding lgamma/digamma/igamma/igammac/erf/errfc to that repository. happy to review your code there.
Activity
girving commentedon Nov 19, 2015
Thanks, special functions are well worth adding, and we'd welcome contributions in this direction.
akuz commentedon Dec 27, 2015
I was just thinking of implementing some Bayesian learning on TensorFlow and realised that I would need the Gamma and also in particular LogGamma (this is just the log of the Gamma function computed directly). These are absolutely essential for many distributions (Beta, Dirichlet). I would love to help to add them, however could you please provide some small guidance on where to start? I see there are many levels of op implementation, description, Python wrapping etc. Thanks
akuz commentedon Dec 28, 2015
Found it: https://www.tensorflow.org/versions/master/how_tos/adding_an_op/index.html
vrv commentedon Dec 28, 2015
@ebrevdo is already half-way to implementing this, I think (I think he added it to Eigen for both CPU and GPU? not sure if it's been upstreamed yet).
ebrevdo commentedon Dec 28, 2015
Yeah; this has been implemented and should make it into the next upstream release. I've added lgamma to Eigen (both ours & upstream) and added an lgamma unary op.
Digamma should also make its way in, in the next 2 weeks.
akuz commentedon Dec 28, 2015
@ebrevdo is it possible for me to pull the lgamma implementation from your repo? I can't see it in your profile, perhaps it's internal at your company, and I can't just pull changes from it? I really need lgamma soon, can't wait ;)
akuz commentedon Dec 28, 2015
@ebrevdo hi, I saw you implemented erf, erfc, and lgamma in Eigen. Why not also implement tgamma from the same section of "cmath" header, just so that all four functions from "Error and gamma functions" section would be available? http://en.cppreference.com/w/cpp/header/cmath
Looking forward for them to become available as TensorFlow operations! Thank you
davmre commentedon Jan 3, 2016
@akuz I've been using a hack where you just define a series expansion within the TF graph. It's not pretty and I don't guarantee accuracy, but if you really can't wait for proper support it might be worth a try:
ebrevdo commentedon Jan 3, 2016
It'll get pushed to the public repo next week.
On Jan 3, 2016 8:49 AM, "David Moore" [email protected] wrote:
ebrevdo commentedon Mar 9, 2016
CPU and GPU versions of lgamma, digamma, erf, and erfc are in, igamma/igammac/betainc are coming soon. Marking as done.
drao2 commentedon Mar 15, 2016
Sorry to dig this up again, but are there any plans to incorporate the polygamma function (1) in the near future? Anything using a Dirichlet / Beta prior distribution will utilise the digamma function, for which the gradient is the polygamma.
ebrevdo commentedon Mar 15, 2016
As far as I can tell, the digamma function is only used for entropy and
other log-expectation calculations. The rest use gamma or log-gamma.
On Tue, Mar 15, 2016 at 4:48 AM, dush64 [email protected] wrote:
drao2 commentedon Mar 15, 2016
That's true - sorry, should have been more specific. The digamma/polygamma come up when computing expectations and KL divergences for dirichlet distributions. Is this general enough to warrant a place in Tensorflow, or should I be independently implementing it (or contributing it)?
ebrevdo commentedon Mar 15, 2016
it is worthwhile to add trigamma or polygamma from cephes. you will have to add it to Eigen first, and verify CUDA support works. see bitbucket.org/eigen/eigen/ and specifically my PRs adding lgamma/digamma/igamma/igammac/erf/errfc to that repository. happy to review your code there.
girving commentedon Mar 15, 2016
However, let's split any new special functions off into a new issue.
ebrevdo commentedon Mar 15, 2016
Agreed; this issue is closed. First push changes to Eigen and then open an issue to bring tri/polygamma into TensorFlow once that's done.
Loop coalescing: fix pointer chainsing in use-chain traversal
Merge pull request tensorflow#291 from ROCmSoftwarePlatform/develop-u…
Update XNNPACK in XLA