问题确实很简单,但似乎无法在 TensorFlow 文档中或通过谷歌搜索找到函数。
如何将类型张量转换tf.int32为类型之一tf.string?
我尝试简单地用这样的东西来投射它:
x = tf.constant([1,2,3], dtype=tf.int32)
x_as_string = tf.cast(x, dtype=tf.string) # hoping for this output: [ '1', '2', '3' ]
with tf.Session() as sess:
res = sess.run(x_as_string)
Run Code Online (Sandbox Code Playgroud)
但点击错误信息:
不支持将 int32 转换为字符串
文档中是否有我缺少的简单功能?
更新:
澄清一下:我意识到我可以使用 python 函数“解决”这个问题,tf.py_func但询问 TensorFlow 本身是否有解决方案
| 归档时间: |
|
| 查看次数: |
4413 次 |
| 最近记录: |