[Q] What is the excact output ConstantOfShape with empty input shape
See original GitHub issueThe definition of ConstantOfShape contains a notable special case:
input: 1D tensor. The shape of the expected output tensor. If empty tensor is given, the output would be a scalar
However the test case for this is missing. I also couldn’t find any other notion how a “scalar” tensor is defined.
So what are the dimensions of the output tensor in this case? To put it in code: Is the following supposed to pass:
graph = self._make_graph([],
[make_node("Constant", [], ['shape'],
value=make_tensor('shape', TensorProto.INT64, (0,), [])), # Empty tensor?
make_node("ConstantOfShape", ['shape'], ['y'], value=make_tensor('value', TensorProto.INT32, (1, ), (2, )))],
[])
self._assert_inferred(graph,
[make_tensor_value_info('shape', TensorProto.INT64, (0,)),
make_tensor_value_info('y', TensorProto.INT32, [])]) # scalar tensor
# Runtime output would be the scalar value "2" in a tensor of an empty shape(?)
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
tensorflow scatter_nd with empty tensors? - Stack Overflow
I thought about using a conditional on the shape of the input, but tf.cond executes both pathways. How can I handle this situation...
Read more >Understanding Tensorflow's tensors shape: static and dynamic
The shape is the number of elements in each dimension, e.g.: a scalar has a rank 0 and an empty shape () ,...
Read more >tf.constant | TensorFlow v2.11.0
Creates a constant tensor from a tensor-like object. ... tf.constant( value, dtype=None, shape=None, name='Const' ) ...
Read more >How to Reshape Input Data for Long Short-Term Memory ...
In this tutorial, you will discover how to define the input layer to LSTM models ... Once reshaped, we can print the new...
Read more >Chapter 14: SOLUTIONS TO TEXT PROBLEMS:
Marginal revenue and marginal cost are graphed in Figure 3. The curves cross at a ... The market price rises to P2, and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

While I agree with the definition of @yuslepukhin (see my example test code) this is nowhere documented. So as documentation about “scalar tensor” and a test case for this special case is missing I wouldn’t close this until that is done.
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.