# tf.contrib.data.assert_element_shape

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/data/python/ops/batching.py#L180-L231) |

Assert the shape of this `Dataset`.

    tf.contrib.data.assert_element_shape(
        expected_shapes
    )

    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.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `expected_shapes` | A nested structure of [`tf.TensorShape`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/TensorShape) objects. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `Dataset` transformation function, which can be passed to [`tf.data.Dataset.apply`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/data/Dataset#apply) ||

<br />