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

tf.zeros_like() and tf.ones_like() do not preserve partial shape information #744

Closed
mrry opened this issue Jan 11, 2016 · 0 comments
Closed
Assignees

Comments

@mrry
Copy link
Contributor

mrry commented Jan 11, 2016

For example:

>>> p = tf.placeholder(tf.float32, [None, 4])
>>> z = tf.zeros_like(p)
>>> z.get_shape()
TensorShape([Dimension(None), Dimension(None)])

This happens because ConstantValue(shape(p)) can't be evaluated completely. We should set the shape of the returned tensor.

@mrry mrry self-assigned this Jan 11, 2016
@mrry mrry changed the title tf.zeros_like and tf.ones_like do not preserve partial shape information tf.zeros_like() and tf.ones_like() do not preserve partial shape information Jan 11, 2016
@vrv vrv closed this as completed in a6037e9 Jan 11, 2016
kentonl pushed a commit to kentonl/tensorflow that referenced this issue Jan 12, 2016
Previously, partial shape information was discarded, because our
constant evaluation for (e.g.) `tf.shape(tf.placeholder([..., None,
...]))` could not produce a Numpy array for the shape. Since the
*_like wrappers have access to the input tensor, we can use
`Tensor.set_shape()` to add back the partial information.

Fixes tensorflow#744.
Change: 111856452
kentonl pushed a commit to kentonl/tensorflow that referenced this issue Jan 12, 2016
Previously, partial shape information was discarded, because our
constant evaluation for (e.g.) `tf.shape(tf.placeholder([..., None,
...]))` could not produce a Numpy array for the shape. Since the
*_like wrappers have access to the input tensor, we can use
`Tensor.set_shape()` to add back the partial information.

Fixes tensorflow#744.
Change: 111856452
kentonl pushed a commit to kentonl/tensorflow that referenced this issue Jan 12, 2016
Previously, partial shape information was discarded, because our
constant evaluation for (e.g.) `tf.shape(tf.placeholder([..., None,
...]))` could not produce a Numpy array for the shape. Since the
*_like wrappers have access to the input tensor, we can use
`Tensor.set_shape()` to add back the partial information.

Fixes tensorflow#744.
Change: 111856452
kentonl pushed a commit to kentonl/tensorflow that referenced this issue Jan 12, 2016
Previously, partial shape information was discarded, because our
constant evaluation for (e.g.) `tf.shape(tf.placeholder([..., None,
...]))` could not produce a Numpy array for the shape. Since the
*_like wrappers have access to the input tensor, we can use
`Tensor.set_shape()` to add back the partial information.

Fixes tensorflow#744.
Change: 111856452
darkbuck pushed a commit to darkbuck/tensorflow that referenced this issue Jan 23, 2020
…random_fix2

Fix for //tensorflow/python:stateful_random_ops_test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant