joddiy commented on a change in pull request #495: SINGA-475 add SoftSign
operator
URL: https://github.com/apache/incubator-singa/pull/495#discussion_r309593540
##########
File path: python/singa/autograd.py
##########
@@ -1828,3 +1828,26 @@ def backward(self, dy):
def leakyrelu(x, a=0.01):
return LeakyRelu(a)(x)[0]
+
+
+class SoftSign(Operation):
+ def __init__(self):
+ super(SoftSign, self).__init__()
+
+ def forward(self, x):
+ # y = x / (1 + np.abs(x))
+ if training:
+ self.input = x
+ x1 = singa.AddFloat(singa.Abs(x),1.0)
+ y = singa.__div__(x,x1)
+
+ return y
+
+ def backward(self, dy):
+ dx = singa.AddFloat(singa.Abs(self.input),1.0)
Review comment:
``` dy/dx = 1 / ( 1 + |x| ) ^ 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:
[email protected]
With regards,
Apache Git Services