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

Method backward

python/singa/autograd.py:824–842  ·  view source on GitHub ↗

Args: dy (CTensor): dL / dy Returns: dx (CTensor): dL / dx

(self, dy)

Source from the content-addressed store, hash-verified

822 return res
823
824 def backward(self, dy):
825 """
826 Args:
827 dy (CTensor): dL / dy
828 Returns:
829 dx (CTensor): dL / dx
830 """
831 dx1mask = singa.GEFloat(self.input, 0.0)
832 dx2 = singa.__mul__(self.mask0, self.slope)
833 dx = singa.__add__(dx1mask, dx2)
834 dx = singa.__mul__(dy, dx)
835 dslope = singa.__mul__(dy, singa.__mul__(self.mask0, self.input))
836 if (type(dy) == float) or self.shape0 == self.shape1:
837 assert self.shape0 == self.shape1, ('should have same shape')
838 return dx, dslope
839 # handle broadcast
840 dx = back_broadcast(self.shape3, self.shape0, dx)
841 dslope = back_broadcast(self.shape3, self.shape1, dslope)
842 return dx, dslope
843
844
845def prelu(x, slope):

Callers

nothing calls this directly

Calls 4

typeFunction · 0.85
back_broadcastFunction · 0.85
__mul__Method · 0.45
__add__Method · 0.45

Tested by

no test coverage detected