添加两个张量,每个张量中至少有一个是 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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
