I am trying to compute the gamma function in Tensorflow. The argument in the function is a sum of a float that comes from the tensor and an imaginary part. Normally, I could just exponentiate the tf.math.lgamma
function, however, it does not accept complex numbers. Is there any workaround that could solve this issue?
Asked
Active
Viewed 169 times
0

marco11
- 235
- 2
- 8
-
1The comment "Add test when the lgamma kernel supports complex numbers" in `tf`'s source code suggest that complex values are not implemented, but might be in future versions. The `lgamma` of `scipy.special` allows for complex values, though. Not sure if this might help. – mikuszefski Oct 31 '19 at 08:03
-
Thanks! I tried `scipy.special.gamma` but it cannot be done for tensors, sadly. I solved my problem - I wrote a function that uses Lanczos Approximation for tensors. Works well! – marco11 Oct 31 '19 at 17:58
-
Hi, good to hear. I somewhat expected that Scipy will not work directly, but that you'll need a wrapper. Rewriting the `lgamma` approximation seems quite a work (unnecessary?). Anyhow, as it works, it's Okey ...Cheers. – mikuszefski Nov 04 '19 at 09:18