Open In App

Python – tensorflow.IndexedSlices.shape Attribute

Last Updated : 28 Jul, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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, )



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads