在 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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
