What is Tensor Size?
Tensor size refers to the total number of elements in a tensor. It is the product of all the dimensions (sizes) of the tensor. In other words, it represents the total amount of data stored in the tensor.
Python3
import tensorflow as tf # Create a tensor tensor = tf.constant([[ 1 , 2 , 3 ], [ 4 , 5 , 6 ]]) # Get the size of the tensor size = tf.size(tensor) print ( "Tensor size:" , size) |
Output:
Tensor size: tf.Tensor(6, shape=(), dtype=int32)
What is Tensor and Tensor Shapes?
Tensors are multidimensional arrays, fundamental to TensorFlow’s operations and computations. Understanding key concepts like tensor shape, size, rank, and dimension is crucial for effectively using TensorFlow in machine learning projects. In this article, we are going to understand tensor and its properties.
Contact Us