Instagram
youtube
Facebook
Twitter

Understanding Tensors

Tensors are a fundamental concept in TensorFlow. Tensors are a multidimensional array with a uniform type, and they can be used to represent all type of data. In this tutorial, we’ll learn the basics on tensors.

What are Tensors?

  • A tensor is a container for data that can be represented as an n-dimensional array.

  • tensors are a generalization of vectors and matrices, that can be used to represent any multidimensional data including images, audio and text.

  • tensors can have any number of dimensions and can be of different shapes and sizes.

Types of tensors - 

  • Scalar tensor: A scalar tensor is a tensor with a single value. we can say it is a tensor with no dimensions.

  • Vector: A vector tensor is a tensor with a single dimension.

  • Matrix: A matrix tensor is a tensor with two dimensions.

  • Higher Order: it is a tensor with more than two dimensions.

Common Tensor Operations - 

  • tf.add(): it is used to add two tensors.

  • tf.multiply(): it is used to multiply two tensors.

  • tf.reshape(): it is used to reshape a tensor

  • tf.concat(): it is used to concatenate tensors.

there are many more operations to perform on tensors.

Representation of Tensor - 

import tensorflow as tf
tensor = tf.constant(42)

Here, we created a scalar tensor with the value of 42.