title: Simple Keras Network in GradientTape: LookupError: No gradient defined for operation 'IteratorGetNext' (op type: IteratorGetNext)
body: <p>I've built a very simple TensorFlow Keras model with a single dense layer.  It works perfectly fine outside a <code>GradientTape</code> block, but inside a <code>GradientTape</code> block it raises <code>LookupError: No gradient defined for operation 'IteratorGetNext' (op type: IteratorGetNext)</code></p>
  
  <p>Code to reproduce:</p>
  
  <pre class="lang-py prettyprint-override"><code>from tensorflow.keras.models import Sequential
  from tensorflow.keras.layers import Dense
  import tensorflow as tf
  import numpy as np
  
  print(tf.__version__)
  
  model = Sequential()
  model.add(Dense(1, input_shape=(16,)))
  
  fake_data = np.random.random((1, 16))
  
  print(model.predict(fake_data).shape) # works
  with tf.GradientTape() as tape:
      print(model.predict(fake_data).shape) # LookupError: No gradient defined for operation 'IteratorGetNext' (op type: IteratorGetNext)
  </code></pre>
  
  <p>This appears to work in TensorFlow 2.0.0, however it fails in TensorFlow 2.1.0 and 2.2.0</p>
  
  <p><a href="https://colab.research.google.com/gist/LryF/f72f8c7852cad04b11bf36ef16f2fadd/lookuperror.ipynb" rel="nofollow noreferrer">Here</a> is a notebook that replicates the issue.</p>