title: RuntimeError: as_numpy_iterator() is not supported while tracing functions
body: <p>while i was using function <code>as_numpy_iterator()</code> got error</p>
  
  <blockquote>
    <p>--------------------------------------------------------------------------- RuntimeError                              Traceback (most recent call
    last)  in ()
    ----> 1 image = get_image_data(image_paths)</p>
    
    <p>1 frames
    /tensorflow-2.1.0/python3.6/tensorflow_core/python/data/ops/dataset_ops.py
    in as_numpy_iterator(self)
        488     """
        489     if not context.executing_eagerly():
    --> 490       raise RuntimeError("as_numpy_iterator() is not supported while tracing "
        491                          "functions")
        492     for component_spec in nest.flatten(self.element_spec):</p>
    
    <p>RuntimeError: as_numpy_iterator() is not supported while tracing
    functions</p>
  </blockquote>
  
  <p>my code is </p>
  
  <pre><code>    # creating a function called get_dataset, which creates a dataset of image data from file paths.
  def get_dataset(image_paths):
    filename_tensor = tf.constant(image_paths)
    dataset = tf.data.Dataset.from_tensor_slices(filename_tensor)
    def _map_fn(filename):
      return decode_image(filename=filename)
    return dataset.map(_map_fn)
  #
  def get_image_data(image_paths):
    dataset = get_dataset(image_paths)
    return list(dataset.as_numpy_iterator())
  image = get_image_data(image_paths)
  </code></pre>
  
  <p>it throws error in using <code>dataset.as_numpy_iterator()</code> . I had used image paths of two array of filename</p>