Do numpy arrays differ from Tensors?

Original article was published by Apoorv Yadav on Deep Learning on Medium


So I was browsing through tensorflow docs on my way to find something to try on and then came across the tf.tensors vs np.array. Now, I always thought okay both of them are far quicker than basic list implementation of python but never thought they would be different so muchhh! This short article is for people who are new to this world looking at the Data Science domain.

What do you need?

Now the article is fairly simple with only one prerequisite — Python. Next if you are aware about numpy arrays and tensors, then you can skip next section and read through the difference. But If you are new, do read the next one carefully.

So What are these fancy arrays?

  1. Numpy Arrays:

Numpy is a package in python which provides us with a lot of utilities for large multidimensional arrays and matrices. I hope you are aware of basic understanding of a matrix ( just the representation part would be enough).

Now the most important part of this package is n-dimensional array or ndarray. This array is different from python arrays/Lists and homogeneous in nature. However the use of these array arise when you need to perform mathematical operations on all the elements. In the case of python arrays, you would have to use loops while numpy provides support for this in efficient manner.

(Optional) Want to dive deeper: https://numpy.org/devdocs/user/absolute_beginners.html

2. Tensors:

Mathematically, a scalar, vector, matrix, all are a tensor. They provide mathematical framework to solve problems in physics. But let’s not go too deep into it.

For us, and in relation to tensorflow (an open source library primarily used for machine learning applications) , a tensor is a multidimensional array with a uniform data type as dtype. You can never update a tensor but create a new one.