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

Method backward

python/singa/autograd.py:3097–3117  ·  view source on GitHub ↗

Args: dy (CTensor): the gradient tensor from upper operations Returns: a tuple for (*dx), dx is data for dL / dx.

(self, dy)

Source from the content-addressed store, hash-verified

3095 return res
3096
3097 def backward(self, dy):
3098 """
3099 Args:
3100 dy (CTensor): the gradient tensor from upper operations
3101 Returns:
3102 a tuple for (*dx), dx is data for dL / dx.
3103 """
3104 if self.l == 1:
3105 return self.masks[0][0]
3106 else:
3107 ret = []
3108 cumulation = None
3109 for mask0, mask1 in self.masks[::-1]:
3110 if not cumulation:
3111 ret.insert(0, mask1)
3112 cumulation = mask0
3113 else:
3114 ret.insert(0, singa.__mul__(cumulation, mask1))
3115 cumulation = singa.__mul__(cumulation, mask0)
3116 ret.insert(0, cumulation)
3117 return tuple(ret)
3118
3119
3120def min(*l):

Callers

nothing calls this directly

Calls 2

tupleFunction · 0.50
__mul__Method · 0.45

Tested by

no test coverage detected