码迷,mamicode.com
首页 > 其他好文 > 详细

TensorFlow白皮书

时间:2016-12-20 18:01:06      阅读:390      评论:0      收藏:0      [点我收藏+]

标签:for   blog   mode   拓展   direct   pen   ros   insert   有向图   

TensorFlow [1] is an interface for expressing machine learning algorithms, and an implementation for executing such algorithms.

TensorFlow的功能:1、提供接口表达机器学习算法。2、执行这些机器学习算法。

A computation expressed using TensorFlow can be executed with little or no change on a wide variety of heterogeneous systems, ranging from mobile devices such as phones and tablets up to large-

使用TensorFlow表达的计算模型,可以在不做修改或者修改一点后再异构的系统上运行,包括移动设备(手机等)。

scale distributed systems of hundreds of machines and thousands of computational devices such as GPU cards. The system is flexible and can be used to express a wide variety of algorithms, including training and inference algorithms for deep neural network models, and it has been used for conducting research and for deploying machine learning systems into production across more than a dozen areas of computer science and other fields, including speech recognition, computer vision, robotics, information retrieval, natural language processing, geographic information extraction, and computational drug discovery. This paper describes the TensorFlow interface and an implementation of that interface that we have built at Google. The TensorFlow API and a reference implementation were released as an open-source package under the Apache 2.0 license in November, 2015 and are available at www.tensorflow.org.

 

TensorFlow编程模型和基本概念

A TensorFlow computation is described by a directed graph, which is composed of a set of nodes. The graph represents a dataflow computation, with extensions for allowing some kinds of nodes to

一个TensorFlow计算使用一个由节点集合组成的有向图进行描述(简单说:有向张量计算流图)。有向图表达了一个数据流的计算,允许节点保持和更新状态,并且有分支和循环控制结构的功能,控制有向图的执行。客户端使用python或c++语言构造一个计算有向图。下面的例子是用python构建并且执行一个TensorFlow图的程序和执行过程图。

import tensorflow as tf

b = tf.Variable(tf.zeros([100])) # 100-d vector, init to zeroes

W = tf.Variable(tf.random_uniform([784,100],-1,1)) # 784x100 matrix w/rnd vals

x = tf.placeholder(name="x") # Placeholder for input

relu = tf.nn.relu(tf.matmul(W, x) + b) # Relu(Wx+b)

C = [...] # Cost computed as a function # of Relu

s = tf.Session()

for step in xrange(0, 10):

   input = ...construct 100-D input array ... # Create 100-d vector for input

  result = s.run(C, feed_dict={x: input}) # Fetch cost, feeding x=input

  print step, result

技术分享

 

In a TensorFlow graph, each node has zero or more inputs and zero or more outputs, and represents the instantiation of an operation. Values that flow along normal edges in the graph (from outputs

在TensorFlow有向图,每个节点有0个或多个输入和0个或多个输出,并且表示一个操作的实例化(真正的计算)。在图中沿着普通边流动的数据(输出和输入)都是张量。任意维度的数组,可以显式的知名或者在构建图的时候自动推断出来。

有向图中还可以有一种特殊的边,叫做控制依赖:没有数据流过这些边,作用是保证source node的操作必须在destination node执行前完成。

Since our model includes mutable state, control dependencies can be used directly by clients to enforce happens before relationships. Our implementation also sometimes inserts control dependencies

由于我们的模型包含不稳定状态,控制依赖可以被客户端直接用来在产生关系前强制发生???

我们的应用有时也会插入控制依赖,to enforce orderings between otherwise independent operations as a way of, for example, controlling the peak memory usage.

 

操作与核

操作代表一个抽象计算(矩阵相乘、相加)。一个操作有多个属性,必须给出属性信息或者能够在构建图的时候推断出来,以便能实例化一个节点执行操作。一个常见的属性用法是执行多态操作(将两个浮点张量相加或将两个int32类型的张量相加)

核:代表可以在特定设备(cpu/gpu)上执行的特定操作的实现。

TensorFlow的binary定义了一个可用的操作和核的集合,这个集合里面的操作和核是通过注册机制加入的。这个集合是可以通过连接额外的完成注册的操作或核,以达到扩展的目的。

 

会话

会话:客户端通过会话与TensorFlow系统进行交互。要创建计算有向图,会话接口支持额外的方法增加额外的节点或边,以拓展由当前会话维护的图。

The other primary operation supported by the session interface is Run, which takes a set of output names that need to be computed, as well as an optional set of tensors to be fed into the graph in

另外的由会话接口支持的主要操作是Run,输入时需要计算的输出名(product=tf.matmul(m1,m2),这里product就可以作为输入),以及一个可选的可以用来fed的张量(result = sess.run(product) result就是可选张量)。

place of certain outputs of nodes. Using the arguments to Run, the TensorFlow implementation can compute the transitive closure of all nodes that must be executed in order to compute the outputs that were requested, and can then arrange to execute the appropriate nodes in an order that respects their dependencies (as described in more detail in 3.1). Most of our uses of TensorFlow set up a Session with a graph once, and then execute the full graph or a few distinct subgraphs thousands or millions of times via Run calls.

 

待续20161220

 

TensorFlow白皮书

标签:for   blog   mode   拓展   direct   pen   ros   insert   有向图   

原文地址:http://www.cnblogs.com/wangq17/p/6203516.html

(0)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!