有没有办法在TensorFlow中获取TensorFlow字符串的长度?例如,是否有任何函数返回a = tf.constant("Hello everyone", tf.string)as 的长度14而不将字符串传递回Python.
小智 5
这对我有用:
x = tf.constant("Hello everyone")
# Launch the default graph.
with tf.Session() as sess:
print(tf.size(tf.string_split([x],"")).eval())
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2107 次 |
| 最近记录: |