添加兩個張量,每個張量中至少有一個是 SparseTensor 。 (不推薦使用的參數)
用法
tf.compat.v1.sparse_add(
a, b, threshold=None, thresh=None
)參數
-
a第一個操作數;SparseTensor或Tensor。 -
b第二個操作數;SparseTensor或Tensor。至少一個操作數必須是稀疏的。 -
threshold可選的 0-DTensor(默認為0)。確定輸出值/索引對是否占用空間的幅度閾值。如果它們是真實的,它的 dtype 應該與值匹配;如果後者是 complex64/complex128,那麽 dtype 應該相應地是 float32/float64。 -
threshthreshold的已棄用別名。
返回
-
A
SparseTensor或Tensor,表示總和。
拋出
-
TypeError如果a和b都是Tensors。請改用tf.add()。
警告:不推薦使用某些參數:(thresh)。它們將在未來的版本中被刪除。更新說明:不推薦使用 thresh,請改用 threshold
如果傳入了一個 SparseTensor 和一個 Tensor,則返回一個 Tensor 。如果兩個參數都是 SparseTensor ,則返回 SparseTensor 。參數的順序無關緊要。使用 vanilla tf.add() 添加兩個密集的 Tensor s。
兩個操作數的形狀必須匹配:不支持廣播。
假設任何輸入SparseTensor 的索引都按標準字典順序排序。如果不是這種情況,請在此步驟之前運行SparseReorder 以恢複索引順序。
如果兩個參數都是稀疏的,我們執行 "clipping" 如下。默認情況下,如果兩個值在某個索引處總和為零,則輸出SparseTensor 仍將在其索引中包含該特定位置,在相應的值槽中存儲一個零。要覆蓋這一點,調用者可以指定 thresh ,表示如果總和的幅度嚴格小於 thresh ,則不包括其對應的值和索引。特別是,thresh == 0.0(默認)表示保留所有內容,實際閾值僅針對正值發生。
例如,假設兩個稀疏操作數的邏輯和是(致密的):
[ 2]
[.1 0]
[ 6 -.2]
然後,
thresh == 0(默認):將返回所有 5 個索引/值對。thresh == 0.11:隻有 .1 和 0 會消失,剩下的三個索引/值對將被返回。thresh == 0.21:.1、0 和 -.2 將消失。
相關用法
- Python tf.compat.v1.sparse_to_dense用法及代碼示例
- Python tf.compat.v1.sparse_segment_sum用法及代碼示例
- Python tf.compat.v1.sparse_split用法及代碼示例
- Python tf.compat.v1.sparse_reduce_max用法及代碼示例
- Python tf.compat.v1.sparse_merge用法及代碼示例
- Python tf.compat.v1.sparse_concat用法及代碼示例
- Python tf.compat.v1.sparse_placeholder用法及代碼示例
- Python tf.compat.v1.sparse_reduce_sum用法及代碼示例
- Python tf.compat.v1.space_to_batch用法及代碼示例
- Python tf.compat.v1.space_to_depth用法及代碼示例
- Python tf.compat.v1.strings.length用法及代碼示例
- Python tf.compat.v1.scatter_min用法及代碼示例
- Python tf.compat.v1.summary.merge用法及代碼示例
- Python tf.compat.v1.size用法及代碼示例
- Python tf.compat.v1.scatter_add用法及代碼示例
- Python tf.compat.v1.summary.FileWriter用法及代碼示例
- Python tf.compat.v1.scatter_div用法及代碼示例
- Python tf.compat.v1.string_split用法及代碼示例
- Python tf.compat.v1.squeeze用法及代碼示例
- Python tf.compat.v1.set_random_seed用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.compat.v1.sparse_add。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
