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

View source on GitHub

Asserts the cardinality of the input dataset.

dataset ="examples.tfrecord")
cardinality =
print((cardinality ==
dataset = dataset.apply(

expected_cardinality The expected cardinality of the input dataset.

A Dataset transformation function, which can be passed to

FailedPreconditionError The assertion is checked at runtime (when iterating the dataset) and an error is raised if the actual and expected cardinality differ.