Tensors and it's Type

TensorFlow, as the name indicates, is a framework to define and run computations involving tensors.


Tensor has mainly following properties.
1.) a data type(float32int32, or string, for example)
2.) shape
Each element in the Tensor has the same data type, and the data type is always known. 
The shape (that is, the number of dimensions it has and the size of each dimension) might be only partially known.
Below is a type of sensor in tensorflow.

Rank

The rank of a tf.Tensor object is its number of dimensions. 


RankMath entity
0Scalar (magnitude only)
1Vector (magnitude and direction)
2Matrix (table of numbers)
33-Tensor (cube of numbers)
nn-Tensor (you get the idea)

Rank 0

The following snippet demonstrates creating a few rank 0 variables:


mammal = tf.Variable("Elephant", tf.string) ignition = tf.Variable(451, tf.int16) floating = tf.Variable(3.14159265359, tf.float64) its_complicated = tf.Variable(12.3 - 4.85j, tf.complex64)

Rank 1

To create a rank 1 tf.Tensor object, you can pass a list of items as the initial value. For example:



mystr = tf.Variable(["Hello"], tf.string) cool_numbers  = tf.Variable([3.14159, 2.71828], tf.float32) first_primes = tf.Variable([2, 3, 5, 7, 11], tf.int32) its_very_complicated = tf.Variable([12.3 - 4.85j, 7.5 - 6.23j], tf.complex64)

Comments