MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _SparseSliceGrad

Function _SparseSliceGrad

tensorflow/python/ops/sparse_grad.py:120–145  ·  view source on GitHub ↗

The backward operator for the SparseSlice op. This op takes in the upstream gradient w.r.t. non-empty values of the sliced `SparseTensor`, and outputs the gradients w.r.t. the non-empty values of input `SparseTensor`. Args: op: the SparseSlice op *grads: the incoming gradients, one

(op, *grads)

Source from the content-addressed store, hash-verified

118
119@ops.RegisterGradient("SparseSlice")
120def _SparseSliceGrad(op, *grads):
121 """The backward operator for the SparseSlice op.
122
123 This op takes in the upstream gradient w.r.t. non-empty values of
124 the sliced `SparseTensor`, and outputs the gradients w.r.t.
125 the non-empty values of input `SparseTensor`.
126
127 Args:
128 op: the SparseSlice op
129 *grads: the incoming gradients, one element per output of `op`
130
131 Returns:
132 Gradient for each of the 5 input tensors of SparseSlice:
133 (indices, values, shape, start, size)
134 The gradients for the indices, shape, start and the size are None.
135 """
136 backprop_val_grad = grads[1]
137 input_indices = op.inputs[0]
138 input_start = op.inputs[3]
139 output_indices = op.outputs[0]
140
141 val_grad = gen_sparse_ops.sparse_slice_grad(
142 backprop_val_grad, input_indices, input_start, output_indices)
143 val_grad.set_shape(op.inputs[1].get_shape())
144 # (indices, values, shape, start, size)
145 return (None, val_grad, None, None, None)
146
147
148@ops.RegisterGradient("SparseTensorDenseMatMul")

Callers

nothing calls this directly

Calls 2

set_shapeMethod · 0.45
get_shapeMethod · 0.45

Tested by

no test coverage detected