TensorFlow工作笔记002---Centos7.3下TensorFlow使用python创建计算图案例

版权声明:本文为博主原创文章,未经博主credreamer 允许不得转载 违者追究法律责任。 https://blog.csdn.net/lidew521/article/details/88170122

技术交流QQ群【JAVA,.NET,BigData,AI】:170933152  

1.直接看例子吧

>>> import tensorflow as tf
>>> a = tf.constant([1.0,2.0],name="a") //向量集合
>>> b = tf.constant([2.0,3.0],name="b")
>>> result = a + b //向量计算
>>> sess = tf.session() //这里session首字母大写
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'session'
>>> sess = tf.Session()
>>> sess.run(result) //向量输出结果
array([3., 5.], dtype=float32)
>>> print(a.graph is tf.get_default_graph()) 
//a的计算图没有特意指定,就是当前默认计算图所以是true,b也是True
>>> print(b.graph is tf.get_default_graph()) 
True

猜你喜欢

转载自blog.csdn.net/lidew521/article/details/88170122