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

tf.igamma (lower regularized incomplete Gamma function) returns the incorrect derivative #17995

Open
erikbern opened this issue Mar 26, 2018 · 4 comments

Comments

@erikbern
Copy link

commented Mar 26, 2018

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Mac OS X 10.11.6
  • TensorFlow installed from (source or binary): binary (pypi)
  • TensorFlow version (use command below): v1.6.0-0-gd2e24b6039
  • Python version: 3.6
  • Bazel version: using a precompiled version, not sure
  • CUDA/cuDNN version: not using a GPU
  • GPU model and memory: not using a GPU
  • Exact command to reproduce: python igamma_test.py

Describe the problem

tf.igamma, which is the lower regularized incomplete Gamma function, returns an incorrect derivative with respect to a

This is probably very low down on the list of things to fix, but I wanted to highlight it since I spent something like 5 hours trying to understand why my model wasn't converging. I was fitting a Gamma distribution, and deep into the code it turns out that tf.igamma doesn't return the right derivative.

I suspect the derivative wrt a isn't supported, but I would have much rather seen an exception being thrown.

My workaround ended up being not fitting a with gradient descent, but instead just perturbing it by epsilon (luckily I only had one single value that I tried to fit)

Filing this issue mostly in the hope that anyone in the future doesn't waste the same amount of time that I spent.

Source code / logs

a = tf.placeholder(dtype=tf.float32, shape=[None])
x = tf.placeholder(dtype=tf.float32, shape=[None])
y = tf.igamma(a, x)
y_grad_a = tf.gradients(y, a)  # returns None, should return a tensor
y_grad_x = tf.gradients(y, x)  # returns a tensor
@tensorflowbutler

This comment has been minimized.

Copy link
Member

commented Mar 26, 2018

Thank you for your post. We noticed you have not filled out the following field in the issue template. Could you update them if they are relevant in your case, or leave them as N/A? Thanks.
Bazel version
CUDA/cuDNN version
GPU model and memory
Exact command to reproduce

@erikbern

This comment has been minimized.

Copy link
Author

commented Apr 6, 2018

@tensorflowbutler I updated the fields

@rlouf

This comment has been minimized.

Copy link

commented May 29, 2018

I was facing the same issue. The derivative wrt a is indeed not implemented: https://github.com/tensorflow/tensorflow/blob/d8f9538ab48e3c677aaf532769d29bc29a05b76e/tensorflow/python/ops/math_grad.py

@mhuen

This comment has been minimized.

Copy link

commented Nov 19, 2018

Are there any updates on this? This would be really great to have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.