Python – tensorflow.IndexedSlices.shape Attribute
TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning neural networks.
shape is used to get the tensorflow.TensorShape representing the shape of the dense tensor.
Syntax: tensorflow.IndexedSlices.shape
Returns: It returns tensorflow.TensorShape representing the shape of the dense tensor.
Example 1:
Python3
# Importing the libraryimport tensorflow as tf # Initializing the inputdata = tf.constant([[1, 2, 3], [4, 5, 6]]) # Printing the inputprint('data: ', data) # Calculating resultres = tf.IndexedSlices(data, [0], tf.constant([1, 2])) # Finding Shapeshape = res.shape # Printing the resultprint('Shape: ', shape) |
Output:
data: tf.Tensor( [[1 2 3] [4 5 6]], shape=(2, 3), dtype=int32) Shape: (1, 2)
Example 2:
Python3
# Importing the libraryimport tensorflow as tf # Initializing the inputdata = tf.constant([[1, 2, 3], [4, 5, 6]]) # Printing the inputprint('data: ', data) # Calculating resultres = tf.IndexedSlices(data, [0], tf.constant([1])) # Finding Shapeshape = res.shape # Printing the resultprint('Shape: ', shape) |
Output:
data: tf.Tensor( [[1 2 3] [4 5 6]], shape=(2, 3), dtype=int32) Shape: (1, )


Please Login to comment...