In machine learning, data should be represented numerically for better understanding. So what is a tensor? This is especially for a neutral network of data representation which is done by the repository known as the tensor. A tensor is the data structure in the form of a grid that can cope with data up to the Nth dimension. They have descriptions of valid linear transformations and can play a pivotal role by encoding multi-dimensional machine learning data. They collect and store data features in the context of machine learning and deep learning. In this article, we will see what is a tensor?
In this article let us look at:
Tensors are algebraic objects for higher dimensions of scalars, matrices and vectors and are referred to as tensor algebra. They are also known as a multi-dimensional array. It is represented in the form of a grid having an array of numbers and a variable number of axes. It is often interchangeably used for vectors and matrices. So, the difference between vector and matrix is that a vector is a single-dimensional tensor or first-order tensor, whereas a matrix is a two-dimensional tensor or second-order tensor.
Tensors can be used very much effective in pythons, just as vectors and matrices. This can be done by using the N-dimensional array. It can be defined as a list of lists as an in-line to the constructor. 3*3*3 is an example of NumPy ndarray and is easy to get into the brains for better understanding. Rows are first defined over here.
Further, a list of rows is stacked as columns, and a list of columns are categorized as levels in a cube. A three-dimensional tensor is printed in a series of matrices. Each dimension has a layer. In the case of a 3D tensor, the level is specified by axis 0, the row is specified by axis 1, and the column is specified by axis 2.
Tensors are operated in various arithmetic operations. This helps in improving functionality and speedy results. Following are the four main arithmetic operations of a tensor:
ย ย ย ย x111, x121, c131 ย ย x112, x122, x132
A = (x211, x221, c231), ย (x112, x122, x132)
ย ย ย ย y111, y121, y131 ย ย y112, y122, y132
B = (y211, y221, y231), ย (y112, y122, y132)
C = A B
ย ย ย ย ย x111 y111, x121 y121, x131 y131 ย ย x112 y112, x122 y122, x132 y132
C = (x211 y211, x221 y221, x231 y231), ย (x112 y112, x122 y122, x132 y132)
In NumPy, the following would be the data input:
# tensor addition
from numpy import array
A = array([
ย [[1,2,3], ย ย [4,5,6], ย ย [7,8,9]],
ย [[11,12,13], [14,15,16], [17,18,19]],
ย [[21,22,23], [24,25,26], [27,28,29]],
ย ])
B = array([
print(C)
When you run, the following will appear
[[[ 2 ย 4 ย 6]
ย [ 8 10 12]
ย [14 16 18]]
[[22 24 26]
ย [28 30 32]
ย [34 36 38]]
[[42 44 46]
ย [48 50 52]
ย [54 56 58]]]
C= A-B
ย ย x111 – y111, x121 – y121, x131 – y131 ย ย x112 – y112, x122 – y122, x132 – y132
C = (x211 – y211, x221 – y221, x231 – y231), ย (x112 – y112, x122 – y122, x132 – y132)
The following will be the resultant for subtracting the first tensor from the second in NumPy
[[[0 0 0]
ย [0 0 0]
ย [0 0 0]]
[[0 0 0]
ย [0 0 0]]]
C= A o B
x111 * y111, x121 * y121, x131 * y131 ย ย x112 * y112, x122 * y122, x132 * y132
C = (x211 * y211,x221 * y221, x231 * y231), ย (x112 * y112, x122 * y122, x132 * y132)
The following will be the resultant for multiplying the first tensor from the second in NumPy
[[[ ย 1 ย 4 ย 9]
ย [ 16 ย 25 ย 36]
ย [ 49 ย 64 ย 81]]
[[121 144 169]
ย [196 225 256]
ย [289 324 361]]
[[441 484 529]
ย [576 625 676]
ย [729 784 841]]]
C= A / B
x111 / y111, x121 / y121, x131 / y131 ย ย x112 / y112, x122 / y122, x132 / y132
C = (x211 / y211, x221 / y221, x231 / y231), ย (x112 / y112, x122 / y122,x132 / y132)
[[[ 1. ย 1. ย 1.]
ย [ 1. ย 1. ย 1.]
ย [ 1. ย 1. ย 1.]]
[[ 1. ย 1. ย 1.]
The tensor product can be performed on matrices and vectors as well, and it is denoted by โ(x)โ. In the case of a tensor a ย with q dimension and tensor b with p dimension, the resultant product will be q r dimensions. ย ย ย ย ย ย ย ย
Thus, in this article, we have learned what is a tensor? Tensor is a framework for enabling mathematical operations in an optimized way. They are dynamic and often change while interacting with other mathematical entities and offer quick and accurate results.
There are no right or wrong ways of learning AI and ML technologies โ the more, the better! These valuable resources can be the starting point for your journey on how to learn Artificial Intelligence and Machine Learning. Do pursuing AI and ML interest you? If you want to step into the world of emerging tech, you can accelerate your career with thisย Machine Learning And AI Coursesย by Jigsaw Academy.
Fill in the details to know more
From The Eyes Of Emerging Technologies: IPL Through The Ages
April 29, 2023
Personalized Teaching with AI: Revolutionizing Traditional Teaching Methods
April 28, 2023
Metaverse: The Virtual Universe and its impact on the World of Finance
April 13, 2023
Artificial Intelligence โ Learning To Manage The Mind Created By The Human Mind!
March 22, 2023
Wake Up to the Importance of Sleep: Celebrating World Sleep Day!
March 18, 2023
Operations Management and AI: How Do They Work?
March 15, 2023
How Does BYOP(Bring Your Own Project) Help In Building Your Portfolio?
What Are the Ethics in Artificial Intelligence (AI)?
November 25, 2022
What is Epoch in Machine Learning?| UNext
November 24, 2022
The Impact Of Artificial Intelligence (AI) in Cloud Computing
November 18, 2022
Role of Artificial Intelligence and Machine Learning in Supply Chain Managementย
November 11, 2022
Best Python Libraries for Machine Learning in 2022
November 7, 2022
Add your details:
By proceeding, you agree to our privacy policy and also agree to receive information from UNext through WhatsApp & other means of communication.
Upgrade your inbox with our curated newletters once every month. We appreciate your support and will make sure to keep your subscription worthwhile