Reputation: 21
I'm trying to convert a python variable having str format into Tensorflow's Tensor with tf.string data type. Anyone having an idea how to?
Here's what I tried, but it expects data
is already in Tensor format.
print(type(data)) # <type 'str'>
myTensor = tf.convert_to_tensor(data, dtype=tf.string) # ERROR!
Upvotes: 1
Views: 4994
Reputation: 350
I tried to reproduce the error as follows:
myTensor = tf.convert_to_tensor("foo", dtype=tf.string)
print(myTensor)
However the print output is Tensor("Const:0", shape=(), dtype=string) so it seems to be working properly in my case.
I'm not sure why you would get an error.
Upvotes: 3