1

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!
1
  • What is the error? Commented Dec 22, 2017 at 15:24

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.