The creation of tensor object under tensorflow framework.
- The generation of tensors as the input of a computation graph is through tf.constant() and tf.Variable() constructor.
- The basic arithmatic operation between tensors in a given computation node (ops) must be done through specialized operations such as tf.add, tf.mul, etc
- The operations (and the entire graph) on tensors will be executed on a specified device (CPU or GPU).
- The return of the execution of the computation graph is a ndarray of numpy
The programming style of the tensorflow framework.
A complete computation process is defined by a series of computation steps, the output of one step become the input of the next step.
In short, TF adopts functional programming.
TF does not require a "graph" object to be explicitly constructed, rather, "graph" are built through a series of function calls. All functions(ops) defined in the "graph" is carried implicitly with the tensor returned. The run method of session method in the execution phrase will call all function calls carried with the tensor input.
In tensorflow, matrix is represented by a two dimensional list or np array. Row vector is represented by a list, column vector is represented by the transpose of row vector. The vector must be represented in matrix form ([[1, 2]]) in stead of a plain list.
Under the notation of tf, a matrix (tensor) is a column vector which is composed of several row vectors.
N-row is determined by the length of the outer list, N-column is determined by the length of the inner list.
Input/Output of TF Operations
The input of an TF operation is typically tensors (matrix), and the output is typically tensors (matrix) also. Even scalars should be wrapped in tensors (matrices). This implies the flow of datasets.
The output of a tf.reduce_mean() could be a scalar or tensor (ndarray), the output of a tf.matmul() is a tensor (even as a tensor with rank 0).
Indexing and Item assignment on Tensor Object
Indexing on a tensor object is allowed while item assignment is not supported.