Skip to content Skip to sidebar Skip to footer

Can The Map Function Supplied To `tf.data.dataset.from_generator(...)` Resolve A Tensor Object?

I'd like to create a tf.data.Dataset.from_generator(...) dataset. I need to pass in a Python generator. I would like to pass in a property of a previous dataset to the generator l

Solution 1:

TensorFlow now supports passing tensor arguments to the generator:

def map_func(tensor):
    dataset = tf.data.Dataset.from_generator(generator, tf.float32, args=(tensor,))
    return dataset

Solution 2:

The answer is indeed no. Here is a reference to a couple of relevant git issues (open as of the time of this writing) for further developments on the question:

https://github.com/tensorflow/tensorflow/issues/13101

https://github.com/tensorflow/tensorflow/issues/16343

Post a Comment for "Can The Map Function Supplied To `tf.data.dataset.from_generator(...)` Resolve A Tensor Object?"