在 SparseTensor 中保留指定的非空值。
用法
tf.sparse.retain(
sp_input, to_retain
)参数
-
sp_input输入SparseTensor和N非空元素。 -
to_retain一个长度为N且具有M真值的布尔向量。
返回
-
与输入具有相同形状的
SparseTensor和与to_retain中的真实位置相对应的M非空元素。
抛出
-
TypeError如果sp_input不是SparseTensor。
例如,如果 sp_input 具有形状 [4, 5] 和 4 个非空字符串值:
[0, 1]:a
[0, 3]:b
[2, 0]:c
[3, 1]:d
和 to_retain = [True, False, False, True] ,则输出将是形状为 [4, 5] 的 SparseTensor ,具有 2 个非空值:
[0, 1]:a
[3, 1]:d
相关用法
- Python tf.sparse.reduce_sum用法及代码示例
- Python tf.sparse.reduce_max用法及代码示例
- Python tf.sparse.reorder用法及代码示例
- Python tf.sparse.reshape用法及代码示例
- Python tf.sparse.cross用法及代码示例
- Python tf.sparse.mask用法及代码示例
- Python tf.sparse.split用法及代码示例
- Python tf.sparse.to_dense用法及代码示例
- Python tf.sparse.expand_dims用法及代码示例
- Python tf.sparse.maximum用法及代码示例
- Python tf.sparse.bincount用法及代码示例
- Python tf.sparse.concat用法及代码示例
- Python tf.sparse.transpose用法及代码示例
- Python tf.sparse.softmax用法及代码示例
- Python tf.sparse.to_indicator用法及代码示例
- Python tf.sparse.from_dense用法及代码示例
- Python tf.sparse.minimum用法及代码示例
- Python tf.sparse.segment_sum用法及代码示例
- Python tf.sparse.fill_empty_rows用法及代码示例
- Python tf.sparse.slice用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.sparse.retain。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
