tf.compat.v1.sparse_add

View source on GitHub

Adds two tensors, at least one of each is a SparseTensor. (deprecated arguments)

tf.compat.v1.sparse_add(
    a, b, threshold=None, thresh=None
)

Warning: SOME ARGUMENTS ARE DEPRECATED: (thresh). They will be removed in a future version. Instructions for updating: thresh is deprecated, use threshold instead

If one SparseTensor and one Tensor are passed in, returns a Tensor. If both arguments are SparseTensors, this returns a SparseTensor. The order of arguments does not matter. Use vanilla tf.add() for adding two dense Tensors.

The shapes of the two operands must match: broadcasting is not supported.

The indices of any input SparseTensor are assumed ordered in standard lexicographic order. If this is not the case, before this step run SparseReorder to restore index ordering.

If both arguments are sparse, we perform "clipping" as follows. By default, if two values sum to zero at some index, the output SparseTensor would still include that particular location in its index, storing a zero in the corresponding value slot. To override this, callers can specify thresh, indicating that if the sum has a magnitude strictly smaller than thresh, its corresponding value and index would then not be included. In particular, thresh == 0.0 (default) means everything is kept and actual thresholding happens only for a positive value.

For example, suppose the logical sum of two sparse operands is (densified):

[       2]
[.1     0]
[ 6   -.2]

Then,

Args:

Returns:

A SparseTensor or a Tensor, representing the sum.

Raises: