TensorFlow 入门笔记(二)

二 TensorFlow计算模型

2.1 张量-数据模型(tensor)

        在tensorflow中,所有数据都是通过张量来表示的,个人觉得张量很抽象,我是零阶张量为标量,结合一阶张量为向量, 二阶张量为矩阵...来理解的。可以理解为多维数组。

2.2 会话-运行模型(session)

     会话用来执行定义好的运算。计算完成后需要关闭会话释放资源,否则会造成资源泄露。

C:\Users\Confused_Kitten>Python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.__version__
'1.13.1'
>>> a=tf.constant([1.0,2.0],name="a")
>>> b=tf.constant([2.0,3.0],name="b")
>>> result=tf.add(a,b,name="add")
>>> print(result)
Tensor("add:0", shape=(2,), dtype=float32)
>>> sess=tf.Session()
>>> sess.run(result)
array([3., 5.], dtype=float32)
>>> sess.close()
>>>

在执行期间如果出现如下警告,请去参考 https://blog.csdn.net/win7583362/article/details/87722162 这个博主的博客,治标治本的方案都给出了,自行选择解决方案

2019-03-08 10:02:34.712378: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

 

2.1 计算图(graph)

    计算图可以用来隔离张量和计算

    

 

你可能感兴趣的:(Tensorflow)