What is rank of a tensor

This recipe explains what is rank of a tensor

Recipe Objective

What is rank of a tensor?

Rank of a tensor which is denoted as R which is independent of the number of dimensions denoted as N of the underlying space. Firstly we will consider naturally that a physical entity representation done by tensor which may described by magnitude and multiple dimensions simultaneously. Thus the number of Simultaneous direction is denoted as R and is known as the rank of tensor. There are various ways of representing N-dimensional tensor which are:

rank-0 is represented as N^0 = 1 which is a scalar.

rank-1 is represented as N^1 = N which is a vector.

rank-2 is represented as N^2 = NxN which is a matrix.

Explore the BERT Variants - ALBERT vs DistilBERT

Step 1 - Import library

import tensorflow as tf

Step 2 - Take Sample data

Sample_data = tf.constant([[1,1,2],[2,4,5],[9,7,4],[3,4,6]])

Step 3 - Print Results

print("The Rank of Sample tensor is:",tf.rank(Sample_data))

The Rank of Sample tensor is: tf.Tensor(2, shape=(), dtype=int32)

Here the result is about the rank of the Sample tensor, as the rank of the tensor is not same as the matrix rank. Rank of tensor is the number of indices which is required for uniqely selecting each element of the tensor.

What Users are saying..

profile image

Ameeruddin Mohammed

ETL (Abintio) developer at IBM
linkedin profile url

I come from a background in Marketing and Analytics and when I developed an interest in Machine Learning algorithms, I did multiple in-class courses from reputed institutions though I got good... Read More

Relevant Projects

Build a Churn Prediction Model using Ensemble Learning
Learn how to build ensemble machine learning models like Random Forest, Adaboost, and Gradient Boosting for Customer Churn Prediction using Python

OpenCV Project to Master Advanced Computer Vision Concepts
In this OpenCV project, you will learn to implement advanced computer vision concepts and algorithms in OpenCV library using Python.

Abstractive Text Summarization using Transformers-BART Model
Deep Learning Project to implement an Abstractive Text Summarizer using Google's Transformers-BART Model to generate news article headlines.

Learn to Build Generative Models Using PyTorch Autoencoders
In this deep learning project, you will learn how to build a Generative Model using Autoencoders in PyTorch

End-to-End Snowflake Healthcare Analytics Project on AWS-2
In this AWS Snowflake project, you will build an end to end retraining pipeline by checking Data and Model Drift and learn how to redeploy the model if needed

Insurance Pricing Forecast Using XGBoost Regressor
In this project, we are going to talk about insurance forecast by using linear and xgboost regression techniques.

LLM Project to Build and Fine Tune a Large Language Model
In this LLM project for beginners, you will learn to build a knowledge-grounded chatbot using LLM's and learn how to fine tune it.

Digit Recognition using CNN for MNIST Dataset in Python
In this deep learning project, you will build a convolutional neural network using MNIST dataset for handwritten digit recognition.

Build ARCH and GARCH Models in Time Series using Python
In this Project we will build an ARCH and a GARCH model using Python

Build Deep Autoencoders Model for Anomaly Detection in Python
In this deep learning project , you will build and deploy a deep autoencoders model using Flask.