tf.contrib.data.assert_element_shape
Stay organized with collections
Save and categorize content based on your preferences.
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.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.contrib.data.assert_element_shape\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/data/python/ops/batching.py#L180-L231) |\n\nAssert the shape of this `Dataset`. \n\n tf.contrib.data.assert_element_shape(\n expected_shapes\n )\n\n shapes = [tf.TensorShape([16, 256]), tf.TensorShape([None, 2])]\n result = dataset.apply(tf.data.experimental.assert_element_shape(shapes))\n print(result.output_shapes) # ==\u003e \"((16, 256), (\u003cunknown\u003e, 2))\"\n\nIf dataset shapes and expected_shape, are fully defined, assert they match.\nOtherwise, add assert op that will validate the shapes when tensors are\nevaluated, and set shapes on tensors, respectively.\n\nNote that unknown dimension in `expected_shapes` will be ignored.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------------|----------------------------------------------------------------------------|\n| `expected_shapes` | A nested structure of [`tf.TensorShape`](../../../tf/TensorShape) objects. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `Dataset` transformation function, which can be passed to [`tf.data.Dataset.apply`](../../../tf/data/Dataset#apply) ||\n\n\u003cbr /\u003e"]]