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

Method backward

python/singa/autograd.py:3025–3041  ·  view source on GitHub ↗

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

(self, dy)

Source from the content-addressed store, hash-verified

3023 return res
3024
3025 def backward(self, dy):
3026 """
3027 Args:
3028 dy (CTensor): the gradient tensor from upper operations
3029 Returns:
3030 a tuple for (da, db), da is data for dL / da, db is data
3031 for dL / db.
3032 """
3033 dx0 = dy
3034 dx1 = singa.MultFloat(dy, -1.0)
3035 if (type(dy) == float) or self.shape0 == self.shape1:
3036 assert self.shape0 == self.shape1, ('should have same shape')
3037 return dx0, dx1
3038 # handle broadcast
3039 dx0 = back_broadcast(self.shape3, self.shape0, dx0)
3040 dx1 = back_broadcast(self.shape3, self.shape1, dx1)
3041 return dx0, dx1
3042
3043
3044def sub(a, b):

Callers

nothing calls this directly

Calls 2

typeFunction · 0.85
back_broadcastFunction · 0.85

Tested by

no test coverage detected