我正在尝试将具有str格式的python变量转换为具有tf.string数据类型的Tensorflow的Tensor。任何人都知道如何?
这是我尝试过的,但它预计data
已经采用Tensor格式。
print(type(data)) # <type 'str'>
myTensor = tf.convert_to_tensor(data, dtype=tf.string) # ERROR!
我试图重现错误如下:
myTensor = tf.convert_to_tensor("foo", dtype=tf.string)
print(myTensor)
但是打印输出是Tensor(“Const:0”,shape =(),dtype = string)所以它似乎在我的情况下正常工作。
我不确定你为什么会收到错误。