singa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wang...@apache.org
Subject [1/2] incubator-singa git commit: SINGA-245 Float as the first operand can not multiply with a tensor object
Date Thu, 08 Sep 2016 14:50:17 GMT
Repository: incubator-singa
Updated Branches:
  refs/heads/master 0416a0fdf -> 0ebce1a44


SINGA-245 Float as the first operand can not multiply with a tensor object


Project: http://git-wip-us.apache.org/repos/asf/incubator-singa/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-singa/commit/76cd806e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/76cd806e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/76cd806e

Branch: refs/heads/master
Commit: 76cd806e7f52f609ea603aece9d0ed21b68d67c1
Parents: 0416a0f
Author: Ruan Pingcheng <ruanpingcheng@gmail.com>
Authored: Wed Sep 7 22:09:43 2016 +0800
Committer: Ruan Pingcheng <ruanpingcheng@gmail.com>
Committed: Thu Sep 8 14:08:56 2016 +0800

----------------------------------------------------------------------
 src/python/singa/loss.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/76cd806e/src/python/singa/loss.py
----------------------------------------------------------------------
diff --git a/src/python/singa/loss.py b/src/python/singa/loss.py
index c88290b..8b99ad3 100644
--- a/src/python/singa/loss.py
+++ b/src/python/singa/loss.py
@@ -105,7 +105,7 @@ class SquaredError(Loss):
     It is implemented using Python Tensor operations.
     '''
     def __init__(self):
-        super(Loss, SquaredError).__init__()
+        super(Loss, self).__init__()
         self.err = None
 
     def forward(self, flag, x, y):
@@ -122,7 +122,7 @@ class SquaredError(Loss):
             a Tensor with one error value per sample
         '''
         self.err = x - y
-        return 0.5 * tensor.squared(self.err)
+        return tensor.square(self.err) * 0.5
 
     def backward(self):
         '''Compute the gradient of x w.r.t the error.
@@ -138,4 +138,4 @@ class SquaredError(Loss):
         Returns:
             a float value as the averaged error
         '''
-        return tensor.sum(0.5 * tensor.squared(x - y)) / x.size()
+        return tensor.sum(tensor.square(x - y) * 0.5) / x.size()


Mime
View raw message