(A) TensorFlow frame Introduction

The next series will be updated blog, introduce TensorFlow getting started, as detailed as possible.

 

This paper outlines:

说明TensorFlow的数据流图结构

 

1, the data flow described in FIG.

      

 

        

 TensorFlow employed is a data flow graph (data flow graphs), open source software library for numerical calculation. Node (Operation) represented by mathematical operations in the drawing , in FIG line (Edges) , said inter-node links in the multidimensional data array , i.e. tensor (tensor).

2, Case: TensorFlow achieve an adder

2.1 Code

# Realize a summation 
CON_A = tf.constant (3.0 ) 
con_b = tf.constant (4.0 ) 

sum_ = tf.add (CON_A, con_b) 

with tf.Session () AS Sess: 
    Print (sess.run (sum_))

Note: At this point will always be a bunch of red warning, ignored or enter the following code can be shielded.

He warned that your CPU supports AVX accelerates the linear algebra operations that dot product, matrix multiplication, convolution and so on. May be compiled from the source code installed TensorFlow, of course, you can choose to close

import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'

2.2 TensorFlow结构分析

TensorFlow 程序通常被组织成一个构建图阶段和一个执行图阶段

在构建阶段,op(op指的就是上面说的节点,表示数学操作,如加法,乘法,点积等)的执行步骤被描述成一个图。

在执行阶段,使用会话执行执行图中的 op。

  • 图和会话 :
    • 图:这是 TensorFlow 将计算表示为指令之间的依赖关系的一种表示法
    • 会话(Session):TensorFlow 跨一个或多个本地或远程设备运行数据流图的机制
  • 张量:TensorFlow 中的基本数据对象
  • 节点:提供图当中执行的操作

简单地说,tf框架中,代码的执行都要在会话中进行,而这里所说的图往往指的都是默认图,不需要我们去指定。因此我们只要开启会话,(在默认图中)执行代码即可,代码所执行的操作,我们称之op,即节点。

Guess you like

Origin www.cnblogs.com/kongweisi/p/11038395.html