Python – tensorflow.IndexedSlicesSpec()
TensorFlow 是由 Google 设计的开源Python库,用于开发机器学习模型和深度学习神经网络。
IndexedSlicesSpec继承自 TypeSpec 并为 IndexedSlices 提供类型规范。
Syntax: tensorflow.IndexedSlicesSpec( shape, dtype, indices_dtype, dense_shape_dtype, indices_shape )
Parameters:
- shape(optional): It defines the dense shape of IndexedSlices. Default value is None which allows any dense shape.
- dtype(optional): It defines the dtype of IndexedSlices values. Default value is float32.
- indices_dtype(optional): It defines the dtype of indices in the IndexedSlices. It can either be int32 or int64 with default value int64.
- dense_shape_dtye(optional): It defines the dtype of dense shape in the IndexedSlices. It can either be int32, int64 or None with default value None.
- indices_shape(optional): It defines the shape of the indices component, which indicates how many slices are in the IndexedSlices.
示例 1:此示例使用所有默认值。
Python3
# Importing the library
import tensorflow as tf
# Calculating result
res = tf.IndexedSlicesSpec()
# Printing the result
print('IndexedSlicesSpec: ', res)
Python3
# Importing the library
import tensorflow as tf
# Calculating result
res = tf.IndexedSlicesSpec((2, 3))
# Printing the result
print('IndexedSlicesSpec: ', res)
输出:
IndexedSlicesSpec: IndexedSlicesSpec(TensorShape(None), tf.float32, tf.int64, None, TensorShape([None]))
示例 2:
Python3
# Importing the library
import tensorflow as tf
# Calculating result
res = tf.IndexedSlicesSpec((2, 3))
# Printing the result
print('IndexedSlicesSpec: ', res)
输出:
IndexedSlicesSpec: IndexedSlicesSpec(TensorShape([2, 3]), tf.float32, tf.int64, None, TensorShape([None]))