I’ve ran in to similar problems before when part of the input is not a Tensor. I think tf.data builds a graph and might have problems with NumPy arrays. What happens if you wrap your function in tf.numpy_function: tf.numpy_function  |  TensorFlow Core v2.5.0 70