Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

documentation improvement for tf.debugging.assert_shapes #37344

Merged
merged 1 commit into from
Mar 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 25 additions & 12 deletions tensorflow/python/ops/check_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -1634,8 +1634,8 @@ def assert_shapes_v2(shapes, data=None, summarize=None, message=None,
prefix) are both treated as having a single dimension of size one.

Args:
shapes: dictionary with (`Tensor` to shape) items. A shape must be an
iterable.
shapes: dictionary with (`Tensor` to shape) items, or a list of
(`Tensor`, shape) tuples. A shape must be an iterable.
data: The tensors to print out if the condition is False. Defaults to error
message and first few entries of the violating tensor.
summarize: Print this many entries of the tensor.
Expand All @@ -1658,14 +1658,27 @@ def assert_shapes(shapes, data=None, summarize=None, message=None, name=None):

Example:

```python
tf.assert_shapes([
(x, ('N', 'Q')),
(y, ('N', 'D')),
(param, ('Q',)),
(scalar, ())
])
```
>>> n = 10
>>> q = 3
>>> d = 7
>>> x = tf.zeros([n,q])
>>> y = tf.ones([n,d])
>>> param = tf.Variable([1.0, 2.0, 3.0])
>>> scalar = 1.0
>>> tf.debugging.assert_shapes([
... (x, ('N', 'Q')),
... (y, ('N', 'D')),
... (param, ('Q',)),
... (scalar, ()),
... ])

>>> tf.debugging.assert_shapes([
... (x, ('N', 'D')),
... (y, ('N', 'D'))
... ])
Traceback (most recent call last):
...
ValueError: ...

Example of adding a dependency to an operation:

Expand Down Expand Up @@ -1693,8 +1706,8 @@ def assert_shapes(shapes, data=None, summarize=None, message=None, name=None):
prefix) are both treated as having a single dimension of size one.

Args:
shapes: dictionary with (`Tensor` to shape) items. A shape must be an
iterable.
shapes: dictionary with (`Tensor` to shape) items, or a list of
(`Tensor`, shape) tuples. A shape must be an iterable.
data: The tensors to print out if the condition is False. Defaults to error
message and first few entries of the violating tensor.
summarize: Print this many entries of the tensor.
Expand Down