Skip to content

tf.GradientTape.gradient raise error with tf.nn.relu6 #21380

@YaboSu

Description

@YaboSu

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):
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
  • TensorFlow installed from (source or binary):
  • TensorFlow version (use command below): 1.10.0-rc1
  • Python version: 3.6
  • Bazel version (if compiling from source):
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version:
  • GPU model and memory:
  • Exact command to reproduce:

Describe the problem

tf.GradientTape.gradient raise error with tf.nn.relu6

Source code / logs

import tensorflow as tf

tf.enable_eager_execution()
w = tf.contrib.eager.Variable([[1.0]])
with tf.GradientTape() as tape:
    loss = tf.nn.relu6(w * w)
grad = tape.gradient(loss, w)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/eager/backprop.py", line 858, in gradient
    output_gradients=output_gradients)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/eager/imperative_grad.py", line 63, in imperative_grad
    tape._tape, vspace, target, sources, output_gradients)  # pylint: disable=protected-access
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/eager/backprop.py", line 116, in _gradient_function
    return grad_fn(mock_op, *out_grads)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/nn_grad.py", line 387, in _Relu6Grad
    return gen_nn_ops.relu6_grad(grad, op.outputs[0])
TypeError: 'NoneType' object is not subscriptable

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions