- Tensorflow把计算的定义和执行很好的分离开来,使得整个模型跑起来仅需要两步:
第一步:描绘整幅图(定义计算)
第二步:在session当中执行图中的运算
在上幅图里:
节点: operators, variables, and constants
边: tensors
下面举几个具体实例来说明Graph和Session:
import tensorflow as tf
a=tf.add(3,5)
print(a)
上述代码只是描述了一幅图(为上述步骤中的第一步),并未执行计算,得到的结果只是描述了张量的一些属性,结果如下:
>>Tensor("Add:0",shape=(),dtype=int32)
<