02 Tensorflow Hello World程序


    打开python idle,输入:

 1 import tensorflow as tf
 2 
 3 # 创建常量
 4 hello = tf.constant('Hello,world!')
 5 
 6 # 创建会话
 7 sess = tf.Session()
 8 
 9 # 执行
10 result = sess.run(hello)
11 
12 # 关闭会话
13 sess.close()
14 
15 # 输出结果
16 print(result)

    运行后,如果得到输出b'Hello,world!',证明运行成功。

    注意事项:

        1、Python3.0以后,使用print result会报错,改为print(result)即可。

   


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM