You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@singa.apache.org by GitBox <gi...@apache.org> on 2019/09/18 02:44:14 UTC
[GitHub] [incubator-singa] pinpom commented on a change in pull request
#528: SINGA 475 - add logical operator: and, or, xor, not & negative,
reciprocal
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_r325461738
##########
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:
i think the equation is not correct if a = -b (element-wise)
----------------------------------------------------------------
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