singa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-singa] pinpom commented on a change in pull request #528: SINGA 475 - add logical operator: and, or, xor, not & negative, reciprocal
Date Wed, 18 Sep 2019 03:46:45 GMT
pinpom commented on a change in pull request #528: SINGA 475 - add logical operator: and, or,
xor, not & negative, reciprocal
URL: https://github.com/apache/incubator-singa/pull/528#discussion_r325471648
 
 

 ##########
 File path: python/singa/autograd.py
 ##########
 @@ -2522,3 +2523,144 @@ def backward(self, dy):
 def max(a,b):
     return Max()(a,b)[0]
 
+
+class And(Operation):
+    def __init__(self):
+        super(And, self).__init__()
+
+    def forward(self, a, b):
+        m = singa.__div__(a,b)
+
+        mask0 = singa.GEFloat(m,1)
+        mask1 = singa.LEFloat(m,1)
+        cur = singa.__mul__(mask0,mask1)
+
+        return cur
+
+    def backward(self, dy):
+        assert 0,('no gradient')
+        return None
+
+def _and(a,b):
+    return And()(a,b)[0]
+
+
+class Or(Operation):
+    def __init__(self):
+        super(Or, self).__init__()
+
+    def forward(self, a, b):
+        #find equal element-wise
+        m = singa.__sub__(a,b)
 
 Review comment:
   ok got it. just changed the code already.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message