ShichengChen commented on a change in pull request #496: SINGA-474 Mean operator
URL: https://github.com/apache/incubator-singa/pull/496#discussion_r313862676
 
 

 ##########
 File path: python/singa/autograd.py
 ##########
 @@ -354,6 +354,41 @@ def backward(self, dy):
         return singa.__mul__(dy, dx)
 
 
+def relu(x):
+    return ReLU()(x)[0]
+
+class Mean(Operation):
+    def __init__(self):
+        super(Mean, self).__init__()
+
+    def forward(self, *l):
+        """
+        Args:
+            l: a list of CTensor
+            element-wise mean operator
+        Returns:
+            a new CTensor
+        """
+        if training:
+            self.l = len(l)
+        assert(len(l)>0);
+        x = l[0]
+        for i in range(1,len(l)):
+            x = singa.__add__(x,l[i])
 
 Review comment:
   ```
   x=tensor and set tensor to zero
   for i in range(len(l)):
       x += l[i]
   ```
   Is that what you mean?
   

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


With regards,
Apache Git Services

Reply via email to