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

Gradients.gradients can't handle unused null gradients #147

Closed
Spiess opened this issue Jan 23, 2019 · 1 comment
Closed

Gradients.gradients can't handle unused null gradients #147

Spiess opened this issue Jan 23, 2019 · 1 comment

Comments

@Spiess
Copy link

Spiess commented Jan 23, 2019

I am using a custom operation with three result outputs. When I use Gradients.gradients to obtain the gradient with respect to the first of these outputs, the program crashes with a NullPointerException as the initial gradient for one of the other two outputs is null.

The gradient for this output is never used by my custom GradientFn, but since the change from GradientRegistry to GradientFn all output gradients are cast to their respective type in Op.scala line 1501, even if they are null (in which case a NullPointerException is thrown).

What I'm trying used to work with TensorFlow Scala 0.2.4 and works as intended if I compile TensorFlow Scala 0.4.2-SNAPSHOT after changing line 1501 in org/platanios/tensorflow/api/ops/Op.scala from

outputs.map(_.toOutput.asInstanceOf[Output[T]])

to

outputs.map(o => if (o == null) null else o.toOutput.asInstanceOf[Output[T]])
@eaplatanios
Copy link
Owner

@Spiess Thanks a lot for catching this! I'll push a fix and include it in the next release. :)

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

No branches or pull requests

2 participants