Missed TensorFlow Dev Summit? Check out the video playlist. Watch recordings


View source on GitHub

Build a new dataset that probabilistically returns examples.

    a, b, a_probability, op_seed=None


  • a: the first tf.data.Dataset.
  • b: the second tf.data.Dataset.
  • a_probability: the float probability to select the next example from the a dataset.
  • op_seed: an optional int seed for the TensorFlow PRNG op. Strongly recommended to only use in unittests. Note: only setting this seed will not enable deterministic behavior, callers must also use tf.random.set_seed to enable deterministic behavior.


A tf.data.Dataset that returns examples from dataset a with probability a_probability, and examples form dataset b with probability (1 - a_probability). The dataset will yield the number of examples equal to the smaller of a or b.