MCPcopy Create free account
hub / github.com/apache/singa / backward

Method backward

python/singa/autograd.py:4125–4139  ·  view source on GitHub ↗

backward of ReduceMean Args: dy (CTensor): gradient tensor. Returns: the gradient tensor over input tensor.

(self, dy)

Source from the content-addressed store, hash-verified

4123 return _x
4124
4125 def backward(self, dy):
4126 """
4127 backward of ReduceMean
4128 Args:
4129 dy (CTensor): gradient tensor.
4130 Returns:
4131 the gradient tensor over input tensor.
4132 """
4133 x_shape, x = self.cache
4134 dy = singa.Reshape(dy, x_shape)
4135 mask = singa.Tensor(list(x.shape()), x.device())
4136 mask.SetFloatValue(1.0)
4137 dy = singa.__mul__(mask, dy)
4138 dy = singa.MultFloat(dy, self.scale)
4139 return dy
4140
4141
4142def reduce_mean(x, axes=None, keepdims=1):

Callers

nothing calls this directly

Calls 4

TensorMethod · 0.80
shapeMethod · 0.80
deviceMethod · 0.80
__mul__Method · 0.45

Tested by

no test coverage detected