使用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-my/kKTT2G0BMH2_cNUgsTUN.html