I am trying Tensorflow 2.0 alpha preview and was testing the Eager execution . My doubt is that if you have a numpy array of variable size in middle like
JavaScript
x
9
1
input.shape
2
(10,)
3
4
input[0].shape
5
(109, 16)
6
7
input[1].shape
8
(266, 16)
9
and so on for the rest of the array , how does one eagerly convert them to tensors.
when I try
JavaScript
1
2
1
tf.convert_to_tensor(input)
2
or
JavaScript
1
2
1
tf.Variable(input)
2
I get
ValueError: Failed to convert numpy ndarray to a Tensor (Unable to get element as bytes.).
Converting each sub-array works , but because the sub-array size isn’t same , tf.stack doesn’t work.
Any help or suggestions ?
Advertisement
Answer
This was happening to me in eager as well. Looking at the docs here , I ended up trying
JavaScript
1
2
1
tf.convert_to_tensor(input, dtype=tf.float32)
2
And that worked for me.