nudles commented on a change in pull request #510: SINGA 475 - add min operator
URL: https://github.com/apache/incubator-singa/pull/510#discussion_r314147627
 
 

 ##########
 File path: python/singa/autograd.py
 ##########
 @@ -1945,3 +1945,29 @@ def backward(self, dy):
 
 def sub(a, b):
     return Sub()(a,b)[0]
+
+
+class Min(Operation):
+    def __init__(self):
+        super(Min, self).__init__()    
+    
+    def forward(self, a, b):
+        m = singa.__sub__(a,b)
+        mask0 = singa.LTFloat(m,0) 
+        mask00 = singa.__mul__(singa.LEFloat(m,0),a)
+        mask1 = singa.GTFloat(m,0)
+        mask11=singa.__mul__(mask1,b)
+        mask = singa.__add__(mask00,mask11)
+        
+        if training:
+            self.mask = mask
 
 Review comment:
   then there is no need to store it in self.mask.

----------------------------------------------------------------
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