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'

复制代码
相关文章
相关标签/搜索
本站公众号
   欢迎关注本站公众号,获取更多信息