Data model
The data model in TensorFlow is represented by tensors. Without using complex mathematical definitions, we can say that a tensor (in TensorFlow) identifies a multidimensional numerical array.
This data structure is characterized by three parameters--Rank, Shape, and Type.
Rank
Each tensor is described by a unit of dimensionality called rank. It identifies the number of dimensions of the tensor, for this reason, a rank is a known-as order or n-dimensions of a tensor. A rank zero tensor is a scalar, a rank one tensor ID a vector, while a rank two tensor is a matrix.
The following code defines a TensorFlow scalar, a vector, a matrix and a cube_matrix, in the next example we show how the rank works:
import tensorflow as tf scalar = tf.constant(100) vector = tf.constant([1,2,3,4,5]) matrix = tf.constant([[1,2,3],[4,5,6]]) cube_matrix = tf.constant([[[1],[2],[3]],[[4],[5],[6]],[[7],[8],[9]]]) print(scalar.get_shape()) print(vector.get_shape()) print(matrix.get_shape()) print(cube_matrix...