Tensorflow2.0-HelloWord

源碼

import tensorflow as tf
# tensorflow 2.0 不在有Session 須要這樣處理
tf.compat.v1.disable_eager_execution()

# 定義常量操做 hello
hello = tf.constant("Hello TensorFlow")
# 建立一個會話
sess = tf.compat.v1.Session()
# 執行常量操做 hello 並打印到標準輸出
print(sess.run(hello))
複製代碼

輸出

2021-05-10 01:03:24.797692: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-05-10 01:03:24.797925: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2021-05-10 01:03:24.798973: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:196] None of the MLIR optimization passes are enabled (registered 0 passes)
b'Hello TensorFlow'

複製代碼
相關文章
相關標籤/搜索
本站公眾號
   歡迎關注本站公眾號,獲取更多信息