Python – tensorflow.IndexedSlices.shape Attribute
Last Updated :
28 Jul, 2020
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
import tensorflow as tf
data = tf.constant([[ 1 , 2 , 3 ], [ 4 , 5 , 6 ]])
print ( 'data: ' , data)
res = tf.IndexedSlices(data, [ 0 ], tf.constant([ 1 , 2 ]))
shape = res.shape
print ( 'Shape: ' , shape)
|
Output:
data: tf.Tensor(
[[1 2 3]
[4 5 6]], shape=(2, 3), dtype=int32)
Shape: (1, 2)
Example 2:
Python3
import tensorflow as tf
data = tf.constant([[ 1 , 2 , 3 ], [ 4 , 5 , 6 ]])
print ( 'data: ' , data)
res = tf.IndexedSlices(data, [ 0 ], tf.constant([ 1 ]))
shape = res.shape
print ( 'Shape: ' , shape)
|
Output:
data: tf.Tensor(
[[1 2 3]
[4 5 6]], shape=(2, 3), dtype=int32)
Shape: (1, )
Share your thoughts in the comments
Please Login to comment...