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

tf.contrib.data.assert_element_shape

View source on GitHub

Assert the shape of this Dataset.

shapes = [tf.TensorShape([16, 256]), tf.TensorShape([None, 2])]
result = dataset.apply(tf.data.experimental.assert_element_shape(shapes))
print(result.output_shapes)  # ==> "((16, 256), (<unknown>, 2))"

If dataset shapes and expected_shape, are fully defined, assert they match. Otherwise, add assert op that will validate the shapes when tensors are evaluated, and set shapes on tensors, respectively.

Note that unknown dimension in expected_shapes will be ignored.

expected_shapes A nested structure of tf.TensorShape objects.

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