Skip to content
Related Articles
Open in App
Not now

Related Articles

Python – tensorflow.IndexedSlices.shape Attribute

Improve Article
Save Article
  • Last Updated : 28 Jul, 2020
Improve Article
Save Article

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 library
import tensorflow as tf
  
# Initializing the input
data = tf.constant([[1, 2, 3], [4, 5, 6]])
  
# Printing the input
print('data: ', data)
  
# Calculating result
res = tf.IndexedSlices(data, [0], tf.constant([1, 2]))
  
# Finding Shape
shape = res.shape
  
# Printing the result
print('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 library
import tensorflow as tf
  
# Initializing the input
data = tf.constant([[1, 2, 3], [4, 5, 6]])
  
# Printing the input
print('data: ', data)
  
# Calculating result
res = tf.IndexedSlices(data, [0], tf.constant([1]))
  
# Finding Shape
shape = res.shape
  
# Printing the result
print('Shape: ', shape)

Output:


data:  tf.Tensor(
[[1 2 3]
 [4 5 6]], shape=(2, 3), dtype=int32)
Shape:  (1, )


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!