我想将 tf.int32
类型的张量转换为 tf.string
类型的张量。
感谢this answer我知道在 1.12 版本中我可以使用 tf.strings.format
:
import tensorflow as tf
x = tf.constant([1, 2, 3], dtype=tf.int32)
x_as_string = tf.map_fn(lambda xi: tf.strings.format('{}', xi), x, dtype=tf.string)
with tf.Session() as sess:
res = sess.run(x_as_string)
print(res)
# [b'1' b'2' b'3']
但我想在 Google cloud ml-engine 上执行此操作,该引擎(今天)仅支持最高版本 1.10。
我可以在早期版本的tensorflow中使用替代操作吗?
或者,是否可以在 Google 云 ml-engine 中使用新版本的 TensorFlow?
最佳答案
tf.as_string
应该可以将整数转换为字符串。
关于python - tensorflow 将 tf.int32 转换为 tf.string 在适合 Google 云 ml-engine 的版本中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53329558/