Python – tensorflow.IndexedSlices.indices 属性

Python – tensorflow.IndexedSlices.indices 属性

TensorFlow是谷歌设计的开源Python库,用于开发机器学习模型和深度学习神经网络。

indices用于查找分片的索引。

语法: tensorflow.IndexedSlices.indices

返回:它返回一个包含分片索引的一维张量。

示例 1:

# Importing the library
import tensorflow as tf
  
# Initializing the input
data = tf.constant([1, 2, 3])
  
# Printing the input
print('data: ', data)
  
# Calculating result
res = tf.IndexedSlices(data, [0])
  
# Finding Graph 
indices = res.indices
  
# Printing the result
print('Indices: ', indices)
Python

输出:

data:  tf.Tensor([1 2 3], shape=(3, ), dtype=int32)
Indices:  [0]

Python

示例 2:

# 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, 1])
  
# Finding Graph 
indices = res.indices
  
# Printing the result
print('Indices: ', indices)
Python

输出:

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


Python

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

Tensorflow 教程