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

Method backward

python/singa/autograd.py:876–891  ·  view source on GitHub ↗

Args: dy(CTensor): dL / dy Return: a tuple for (dx0, dx1), dx0 is data for dL / da, dx1 is data for dL / db.

(self, dy)

Source from the content-addressed store, hash-verified

874 return res
875
876 def backward(self, dy):
877 """
878 Args:
879 dy(CTensor): dL / dy
880 Return:
881 a tuple for (dx0, dx1), dx0 is data for dL / da, dx1 is data
882 for dL / db.
883 """
884 dx0, dx1 = dy, dy
885 if (type(dy) == float) or self.shape0 == self.shape1:
886 assert self.shape0 == self.shape1, ('should have same shape')
887 return dx0, dx1
888 # handle broadcast
889 dx0 = back_broadcast(self.shape3, self.shape0, dx0)
890 dx1 = back_broadcast(self.shape3, self.shape1, dx1)
891 return dx0, dx1
892
893
894def add(a, b):

Callers

nothing calls this directly

Calls 2

typeFunction · 0.85
back_broadcastFunction · 0.85

Tested by

no test coverage detected