使用TensorFlow v2张量的一个简单的“hello world”示例

2019-10-17     人工智能遇见磐创

使用TensorFlow v2张量的一个简单的“hello world”示例

import tensorflow as tf
# 创建一个张量
hello = tf.constant("hello world")
print hello

Output:

tf.Tensor(hello world, shape=(), dtype=string)
# 访问张量的值,调用numpy()
print hello.numpy()

output:

hello world
文章来源: https://twgreatdaily.com/zh-hans/kKTT2G0BMH2_cNUgsTUN.html