• Home
  • About
  • Join Us
  • Contact
Bharat Ideology
  • Insight
  • Culture
  • Economics
  • Parenting
  • Science & Tech
Subscribe
No Result
View All Result
  • Insight
  • Culture
  • Economics
  • Parenting
  • Science & Tech
Subscribe
No Result
View All Result
Bharat Ideology
No Result
View All Result
Home Science & Tech

Introduction to Tensor

by bharatideology
January 10, 2025
in Science & Tech
0
Introduction to Tensor
Share on FacebookShare on Twitter

What is Tensor?

In layman’s terms, a tensor is a way of representing the data in deep learning. A tensor can be a 1-dimensional, a 2-dimensional, a 3-dimensional array, etc. You can think of a tensor as a multidimensional array. In machine learning and deep learning, you have datasets that are high dimensional, in which each dimension represents a different feature of that dataset.

A tensor, is the mathematical representation of a physical entity that may be characterized by magnitude and multiple directions.

Related articles

India’s Digital Revolution: A Quantum Leap Towards a $5 Trillion Dream

Top 10 Generative AI Tools and Platforms Reshaping the Future

And, just like you represent a scalar with a single number and a vector with a sequence of three numbers in a 3-dimensional space, for example, a tensor can be represented by an array of 3R numbers in a 3-dimensional space.

The “R” in this notation represents the rank of the tensor: this means that in a 3-dimensional space, a second-rank tensor can be represented by 3 to the power of 2 or 9 numbers. In an N-dimensional space, scalars will still require only one number, while vectors will require N numbers, and tensors will require N^R numbers. This explains why you often hear that scalars are tensors of rank 0: since they have no direction, you can represent them with one number.

With this in mind, it’s relatively easy to recognize scalars, vectors, and tensors and to set them apart: scalars can be represented by a single number, vectors by an ordered set of numbers, and tensors by an array of numbers with rank.

Consider the following example of a dog versus cat classification problem, where the dataset you’re working with has multiple varieties of both cats and dogs images. Now, in order to correctly classify a dog or a cat when given an image, the network has to learn discriminative features like color, face structure, ears, eyes, the shape of the tail, etc. These features are incorporated by the tensors.

How are tensors different from matrices?

A matrix is a two-dimensional grid of size n×m that contains numbers: you can add and subtract matrices of the same size, multiply one matrix with another as long as the sizes are compatible ((n×m)×(m×p)=n×p), and multiply an entire matrix by a constant.

However, a vector is a matrix with just one row or column. A tensor is often thought of as a generalized matrix. The dimension of the tensor is called its rank. Any rank-2 tensor can be represented as a matrix, but not every matrix is a rank-2 tensor.

Example of Tensors

a) Scalar – A scalar or “rank-0” tensor contains a single value, and no “axes”

rank_0_tensor = tf.constant(4)

print(rank_0_tensor)

Output:

tf.Tensor(4, shape=(), dtype=int32)

b) Vector – A “vector” or “rank-1” tensor is like a list of values. A vector has one axis

rank_1_tensor = tf.constant([2.0, 3.0, 4.0])

print(rank_1_tensor)

Output:

tf.Tensor([2. 3. 4.], shape=(3,), dtype=float32)

c) Matrix – A “rank-2” tensor has two axes

rank_2_tensor = tf.constant([[1, 2],

                                                    [3, 4],

                                                    [5, 6]], dtype=tf.float16)

print(rank_2_tensor)

Output –

tf.Tensor(

[[1. 2.]

 [3. 4.]

 [5. 6.]], shape=(3, 2), dtype=float16)

d) Higher dimensional structure – Tensors may have more axes; here is a tensor with three axes

rank_3_tensor = tf.constant([

  [[0, 1, 2, 3, 4],

   [5, 6, 7, 8, 9]],

  [[10, 11, 12, 13, 14],

   [15, 16, 17, 18, 19]],

  [[20, 21, 22, 23, 24],

   [25, 26, 27, 28, 29]],])

print(rank_3_tensor)

Output –

tf.Tensor(

[[[ 0  1  2  3  4]

  [ 5  6  7  8  9]]

 [[10 11 12 13 14]

  [15 16 17 18 19]]

 [[20 21 22 23 24]

  [25 26 27 28 29]]], shape=(3, 2, 5), dtype=int32)

Tags: TensorTensorflow

bharatideology

Related Posts

India’s Digital Revolution: A Quantum Leap Towards a $5 Trillion Dream

India’s Digital Revolution: A Quantum Leap Towards a $5 Trillion Dream

by bharatideology
February 17, 2024
0

The year is 2024, and India stands at a crossroads. The ghosts of the "fragile five" label still linger in the collective memory, but a new...

Top 10 Generative AI Tools and Platforms Reshaping the Future

Top 10 Generative AI Tools and Platforms Reshaping the Future

by bharatideology
January 9, 2025
0

Generative AI, the technology that conjures new ideas and content from thin air, is taking the world by storm. From crafting captivating images to writing eloquent...

Decoding the Future: Gen AI’s Evolution in 2024 – Trends, Strategies, and Business Impact

Decoding the Future: Gen AI’s Evolution in 2024 – Trends, Strategies, and Business Impact

by bharatideology
January 9, 2025
0

Introduction The past year has witnessed an explosive eruption in the realm of Generative AI (Gen AI), propelling it from a nascent technology to a pivotal...

Will Gemini be the AI to Rule Them All? Exploring the Rise of Google’s Multimodal Colossus

Will Gemini be the AI to Rule Them All? Exploring the Rise of Google’s Multimodal Colossus

by bharatideology
January 9, 2025
0

The landscape of Large Language Models (LLMs) has witnessed a rapid evolution, with Google playing a pivotal role in pushing boundaries. Enter Gemini, Google's latest LLM,...

GenAI, LLMs, and Vector Databases: Revolutionizing Recommendation Systems in 2024

GenAI, LLMs, and Vector Databases: Revolutionizing Recommendation Systems in 2024

by bharatideology
January 9, 2025
0

Overview The world of recommendation systems is undergoing a paradigm shift, propelled by the convergence of Generative AI (GenAI) and Large Language Models (LLMs). These powerful...

CATEGORIES

  • Culture
  • Economics
  • Insight
  • Parenting
  • Science & Tech

RECOMMENDED

Build Your Own Computer Vision Models with Python in 6 Easy Steps
Science & Tech

Build Your Own Computer Vision Models with Python in 6 Easy Steps

January 12, 2025
The Echoes of Ayodhya in the Land of Morning Calm: Ramayana in South Korea
Culture

The Echoes of Ayodhya in the Land of Morning Calm: Ramayana in South Korea

January 17, 2024

Twitter Handle

TAGS

Agnipath Ambedkar Panchteerth Artificial Intelligence Ayodhya Ayushman Bharat Backpropogation Bhagwan Birsa Munda Museum CNN CNN Architecture Co-win Computer Vision Consecration Deep Learning Digital India Digital Revolution FutureSkills PRIME GenAI Hornbill Festival Image Segmentation International Space Station LLM Make in India Namami Gange Narendra Modi Neural Network Object Detection OCR OpenCV PLI PM Modi PRASHAD Python Ramayana Ram Mandir Recurrent Neural Network RNN Sangai Festival Semiconductor Shri Ram Janambhoomi Temple Skill India Statue of Unity Swadesh Darshan Tensorflow Vaccine Maitri Women empowerement
Bharat Ideology

Do not be led by others,
awaken your own mind,
amass your own experience,
and decide for yourself your own path - Atharv Ved

© Copyright Bharat Ideology 2023

  • About
  • Disclaimer
  • Terms & Conditions
  • Contact
No Result
View All Result
  • About
  • Contact
  • Disclaimer
  • Home
  • Terms and Conditions of use

© Copyright Bharat Ideology 2023