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

Method forward

python/singa/autograd.py:375–389  ·  view source on GitHub ↗

Args: l (a list of CTensor): a list of CTensor for element-wise mean. Returns: a new CTensor.

(self, *l)

Source from the content-addressed store, hash-verified

373 super(Mean, self).__init__()
374
375 def forward(self, *l):
376 """
377 Args:
378 l (a list of CTensor): a list of CTensor for element-wise mean.
379 Returns:
380 a new CTensor.
381 """
382 if training:
383 self.l = len(l)
384 assert (len(l) > 0)
385 x = singa.Tensor(list(l[0].shape()), l[0].device())
386 x.SetFloatValue(0.0)
387 for i in range(len(l)):
388 x += l[i]
389 return singa.MultFloat(x, 1 / len(l))
390
391 def backward(self, dy):
392 """

Callers

nothing calls this directly

Calls 3

TensorMethod · 0.80
shapeMethod · 0.80
deviceMethod · 0.80

Tested by

no test coverage detected