날짜를 저장하십시오! Google I / O가 5 월 18 일부터 20 일까지 반환됩니다. 지금 등록

tf.data.experimental.assert_cardinality

Asserts the cardinality of the input dataset.

dataset = tf.data.TFRecordDataset("examples.tfrecord")
cardinality = tf.data.experimental.cardinality(dataset)
print((cardinality == tf.data.experimental.UNKNOWN_CARDINALITY).numpy())
True
dataset = dataset.apply(tf.data.experimental.assert_cardinality(42))
print(tf.data.experimental.cardinality(dataset).numpy())
42

expected_cardinality The expected cardinality of the input dataset.

A Dataset transformation function, which can be passed to tf.data.Dataset.apply.

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