tensorflow入门第一步hello world
日常惯例先导入TensorFlow
import tensorflow as tf
常量的定义
hw=tf.constant("hello world!")
我使用比较常用的with方法,把tf.Session()命名给sees,如下:
with tf.Session() as sees:
print(sees.run(hw))
我们输出二进制的hello world,b’hello world!’。
b'hello world!'
我们也可以使用
sees=tf.Session()
print(sees.run(hw))
sees.close()
注意这个需要关掉。close
还有一种方式,记得也需要close。
sees=tf.Session()
print(hw.eval(session=sees))
sees.close()
后续会更新卷积神经网络和循环神经网络的代码,以及应用。
还没有评论,来说两句吧...