python - tensorflow 将 tf.int32 转换为 tf.string 在适合 Google 云 ml-engine 的版本中

标签 python tensorflow google-cloud-ml

我想将 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/

相关文章:

php - Python 和 PHP 没有合作,只有很小的一部分被解析

python - 在 GPU 上训练的模型上设置设备并在 CPU 上进行预测

machine-learning - Keras 中具有有限输出的多目标回归

machine-learning - Cloud ML Engine 中部署的重新训练的 inception_v3 模型始终输出相同的预测

python - "incorrect string value"但可以用 UTF-8 解码

python - 如何让 Python 使用 Assembly

python - 过滤 numpy 数组以仅保留给定值的一行

python - Tensorflow 在类方法调用上设置图形/ session 上下文

google-cloud-ml - 在带有 GPU 队列的 GC ML 上部署 TF 1.0

machine-learning - 将在 Google Cloud 中训练的模型导入到 Android 设备