TF.VARIABLE and TENSOR difference of (turn)

Consideration brush during lessons to the difference between the Variable and Tensor, try to discover in the code as follows: a = tf.Variable (tf.ones (1)) b = tf.add (a, tf.ones (1)) 1 2 a is a Variable, and b is Tensor. He found himself know much about the distinction between Variable and Tensor, so the search for a moment, thinking his record, welcome advice. Variable modifiable (mutable), and Tensor not be changed. A straightforward example is to assign a function that does not have Tensor, comprising the Variable. API differences python and other languages ​​as well as implementation, we only discuss the contents of general terms and python. Variable is used to store the network variables such as the weight matrix, and is more Tensor intermediate results. Variable will allocate memory space (either memory, may be a memory), requires an initialization operation (a Tensor ASSIGN), the Session management, may be stored, read, change and other operations. Conversely, such Const, Zeros Tensor operations such as create, is recorded in the Graph and there is no separate memory space; and other unknown by other operations come Tensor Tensor is only in the middle of running. Local Tensor can use, it can be used almost Variable. Reference: https://stackoverflow.com/questions/37849322/how-to-understand-the-term-tensor-in-tensorflow https://stackoverflow.com/questions/40866675/implementation-difference-between-tensorflow- variable-and-tensorflow-tensor https: // stackoverflow.
 
 
Tags:  tensorflow
Consideration brush during lessons to the difference between the Variable and Tensor, try to discover in the code as follows: a = tf.Variable (tf.ones (1)) b = tf.add (a, tf.ones (1)) 1 2 a is a Variable, and b is Tensor. He found himself know much about the distinction between Variable and Tensor, so the search for a moment, thinking his record, welcome advice. Variable modifiable (mutable), and Tensor not be changed. A straightforward example is to assign a function that does not have Tensor, comprising the Variable. API differences python and other languages ​​as well as implementation, we only discuss the contents of general terms and python. Variable is used to store the network variables such as the weight matrix, and is more Tensor intermediate results. Variable will allocate memory space (either memory, may be a memory), requires an initialization operation (a Tensor ASSIGN), the Session management, may be stored, read, change and other operations. Conversely, such Const, Zeros Tensor operations such as create, is recorded in the Graph and there is no separate memory space; and other unknown by other operations come Tensor Tensor is only in the middle of running. Local Tensor can use, it can be used almost Variable. Reference: https://stackoverflow.com/questions/37849322/how-to-understand-the-term-tensor-in-tensorflow https://stackoverflow.com/questions/40866675/implementation-difference-between-tensorflow- variable-and-tensorflow-tensor https: // stackoverflow.

Guess you like

Origin www.cnblogs.com/jfdwd/p/11184097.html