|View source on GitHub|
Adds two tensors, at least one of each is a
tf.sparse.add( a, b, threshold=0 )
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
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
threshold, indicating that if the sum has a magnitude strictly smaller than
threshold, its corresponding value and index would then not be included. In particular,
threshold == 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]
threshold == 0(the default): all 5 index/value pairs will be returned.
threshold == 0.11: only .1 and 0 will vanish, and the remaining three index/value pairs will be returned.
threshold == 0.21: .1, 0, and -.2 will vanish.
| || The first operand; |
| || The second operand; |
| || A 0-D |
| A |
| || If both |
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.