I have a
tf.tensor which is something like
<tf.Tensor: shape=(3,), dtype=int32, numpy=array([1, 2, 3], dtype=int32)>
Now I know for a fact that the tensor I’ll be getting in that task will just be variants of this tensor that is the shape will be somethin like
(x,) and the it will be an array of x elements.
However I need to set the static shape of this tensor to
[None] so that I can still batch to a ragged tensor with
I tried out using
t.set_shape([None]) but I’m not sure how to check if this did actually set the shape as intended.
How can I check that? and also if this process isn’t right what other ways can I use?
I have a
How about checking the rank of the tensor using
tf.debugging.assert_equal like the below code?
x = ... # type: tf.Tensor # ex> x: <tf.Tensor: shape=(3,), dtype=int32, numpy=array([1, 2, 3], dtype=int32)> tf.debugging.assert_near(tf.rank(x), 1)
or maybe you can reshape tensors to have a
x = tf.reshape(x, [-1])