fix GPU sign...these tests aren't very good

This commit is contained in:
2021-01-03 09:00:49 -08:00
parent ea9c9af5d7
commit 29655609d5
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -67,7 +67,7 @@ class Exp(Function):
class Sign(Function):
@staticmethod
def forward(ctx, input):
return unary_op(ctx, 'a >= 0', input)
return unary_op(ctx, '(a > 0) - (a < 0)', input)
@staticmethod
def backward(ctx, grad_output):
+1 -1
View File
@@ -274,7 +274,7 @@ class Tensor:
return self * (self.softplus().tanh()) # x*tanh(softplus(x))
def abs(self):
return self.relu() + (-1.0*self).relu()
return self * self.sign()
def _pool2d(self, py, px):
xup = self[:, :, :self.shape[2]-self.shape[2]%py, :self.shape[3]-self.shape[3]%px]