Tensors: The building block of TensorFlow

TensorFlow uses tensor to define the framework and processing data. A tensor conceptualized multidimensions vectors and matrices. Mathematically, a tensor is a geometric object that maps in a multi-linear manner geometric vectors, scalars, and another tensor(s) to a resulting tensor.


These tensor objects used to implement a Graph object which coordinated among them self to produce the desired result. A tensor(tf.Tensor) object has the two basic properties that are “Data Type” and “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. Most operations produce tensors of fully-known shapes if the shapes of their inputs are also fully known, but in some cases, it’s only possible to find the shape of a tensor at graph execution time. Apart from this are other possible variables are also there.

Tensor Rank (dimension)

Rank of tensor is the actual dimension of the database. The tensor shape represents the size of each dimension. A 0 rank means zero dimension and represents scalar quantity.

fruit = tf.Variable("Apple", tf.string)
Count = tf.Variable(100, tf.int16)
Weight = tf.Variable(3.14159265359, tf.float64)

Rank 1 means One dimension that is a list of items.

Names = tf.Variable(["Nilesh","Akash","Ritesh"], tf.string) 
Weights  = tf.Variable([100, 110], tf.float32)
GPA = tf.Variable([4,3], tf.int32)

Rank 2 means 2D array that is List of List.

Students = tf.Variable([["Nilesh"],["Ritesh"]], tf.string)
Ages = tf.Variable([[25],[26]], tf.int16)
Tall = tf.Variable([[False], [True]], tf.bool)

 Rank of atf.Tensor object

tf.rank method can be use to determine rank of a object.

r = tf.rank(Students)
# After the graph runs, r will hold the value 2.


 import tensorflow as tf
sess = tf.InteractiveSession()
Students = tf.Variable([["Nilesh"],["Ritesh"]], tf.string)
r = tf.rank(Students)
init = tf.global_variables_initializer()
with sess.as_default():
print_op = tf.print(r)
with tf.control_dependencies([print_op]):
out = tf.add(r, r)
with sess.as_default():
v = sess.run(Students)
(venv) [nilesh@localhost TENSORFLOW]$ 
Instructions for updating:
Colocations handled automatically by placer.


I am Nilesh Kumar, a graduate student at the Department of Biology, UAB under the mentorship of Dr. Shahid Mukhtar. I joined UAB in Spring 2018 and working on Network Biology. My research interests are Network modeling, Mathematical modeling, Game theory, Artificial Intelligence and their application in Systems Biology.

I graduated with master’s degree “Master of Technology, Information Technology (Specialization in Bioinformatics)” in 2015 from Indian Institute of Information Technology Allahabad, India with GATE scholarship. My Master’s thesis was entitled “Mirtron Prediction through machine learning approach”. I worked as a research fellow at The International Centre for Genetic Engineering and Biotechnology, New Delhi for two years.

🐝 Join the Fastest Growing AI Research Newsletter Read by Researchers from Google + NVIDIA + Meta + Stanford + MIT + Microsoft and many others...