mxnet.ndarray.sparse.stop_gradient(data=None, out=None, name=None, **kwargs)

Stops the accumulated gradient of the inputs from flowing through this operator in the backward direction. In other words, this operator prevents the contribution of its inputs to be taken into account for computing gradients.

Example:

v1 = [1, 2]
v2 = [0, 1]
a = Variable('a')
b = Variable('b')

executor = loss.simple_bind(ctx=cpu(), a=(1,2), b=(1,2))
executor.forward(is_train=True, a=v1, b=v2)
executor.outputs
[ 1.  5.]

executor.backward()
[ 0.  0.]
[ 1.  1.]


Defined in src/operator/tensor/elemwise_unary_op_basic.cc:L281

Parameters
• data (NDArray) – The input array.

• out (NDArray, optional) – The output NDArray to hold the result.

Returns

out – The output of this function.

Return type

NDArray or list of NDArrays