Tensorflow教程:Hello World程序
2024-06-21 21:28:55 2025-01-31 08:50:39 李腾 27 次阅读 0 次点赞
打开python idle,输入:
import tensorflow as tf
# 创建常量
hello = tf.constant('Hello,world!')
# 创建会话
sess = tf.Session()
# 执行
result = sess.run(hello)
# 关闭会话
sess.close()
# 输出结果
print(result)
运行后,如果得到输出b'Hello,world!',证明运行成功。
注意事项:
1、Python3.0以后,使用print result会报错,改为print(result)即可。
本文由人工编写,AI优化,请仔细甄别,转载请注明转自www.hylab.cn,原文地址:Tensorflow教程:Hello World程序