ML Community Day is November 9! Join us for updates from TensorFlow, JAX, and more Learn more

tf.data.Options

Represents options for tf.data.Dataset.

Used in the notebooks

Used in the tutorials

A tf.data.Options object can be, for instance, used to control which static optimizations to apply to the input pipeline graph or whether to use performance modeling to dynamically tune the parallelism of operations such as tf.data.Dataset.map or tf.data.Dataset.interleave.

The options are set for the entire dataset and are carried over to datasets created through tf.data transformations.

The options can be set by constructing an Options object and using the tf.data.Dataset.with_options(options) transformation, which returns a dataset with the options set.

dataset = tf.data.Dataset.range(42)
options = tf.data.Options()
options.experimental_deterministic = False
dataset = dataset.with_options(options)
print(dataset.options().experimental_deterministic)
False

dataset = tf.data.Dataset.range(42)
options = tf.data.Options()
options.deterministic = False
dataset = dataset.with_options(options)
print(dataset.options().deterministic)
False

autotune The autotuning options associated with the dataset. See tf.data.experimental.AutotuneOptions for more details.
deterministic Whether the outputs need to be produced in deterministic order. If None, defaults to True.
experimental_deterministic DEPRECATED. Use deterministic instead.
experimental_distribute The distribution strategy options associated with the dataset. See tf.data.experimental.DistributeOptions for more details.
experimental_external_state_policy This option can be used to override the default policy for how to handle external state when serializing a dataset or checkpointing its iterator. There are three settings available - IGNORE: External state is ignored without a warning; WARN: External