TensorFlow basic concepts and functions

A calculating FIG.

TensorFlow the two most important concepts, one Tensor, is a Flow. Tensor is a tensor, Flow is calculated flow. Each node calculation map is a tensor, and the dependencies between the tensor is calculated flow, i.e. in the computation graph by calculating from one stream to another Tensor Tensor.

import tensorflow as tf
a = tf.constant([1.0,2.0], name='a')
b = tf.constant([3.0,4.0], name='b')
result = a + b
In the above code, TensorFlow defined automatically calculated a and b to calculate conversion nodes in the graph. In TensorFlow, the system automatically maintains a default calculated map. And tensor operations on different computing plans are not shared, where we can simply be understood as the concept of scope

By tf.get_default_graph can obtain the current default calculate a function, by tf.Graph () defines a computation graph. FIG addition calculation used to isolate and tensor calculations, may be a separately defined using a GPU computing device in FIG.

In calculating the figures, it can be set collectionto manage resources of different categories, such as by tf.add_to_collectionresources may be added to the set of one or more functions, then through tf.get_collectiona set of all the resources inside the acquisition. The resources here can be a queue resources tensor, variable, or run TensorFlow program needs.

For ease of use, TensorFlow also automatically manage some of the most popular collections:

Second, the tensor (Tensor)

From TensorFlow name can be seen in the tensor (Tensor) is a very important concept, it can be said tensorflow the basic unit. Popular appreciated that in TensorFlow are calculated as a basic unit in Tensor stream. It can also be understood as a multi-dimensional array. In tensor does not really save the number, it is how to get hold of the calculation of these figures .

A tensor saved three main attributes: name: name, dimensions: shape, type: type.

 

Guess you like

Origin www.cnblogs.com/gczr/p/11877535.html