joddiy commented on a change in pull request #484: SINGA -475 add Div operator 
implementation to singa
URL: https://github.com/apache/incubator-singa/pull/484#discussion_r309663270
 
 

 ##########
 File path: python/singa/autograd.py
 ##########
 @@ -1787,6 +1787,22 @@ def abs(a):
     return Abs()(a)[0]
 
 
+class Div(Operation):
+    def _init_(self):
+        super(Div, self)._init_()    
+    
+    def forward(self, a, b):    
+        if training:
+            self.input = (a, b)
+            return singa.__div__(a, b)
+
+    def backward(self, dy):
+        return singa.__div__(dy, self.input[0]), singa.__mul__(dy, 
self.input[1])
 
 Review comment:
   the gradients should be:
   dy/dx_1 = b^-1
   dy/dx_2 = -a*b^-2

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to