From dev-return-3312-archive-asf-public=cust-asf.ponee.io@singa.incubator.apache.org Wed Aug 14 09:08:59 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 9A1C71802C7 for ; Wed, 14 Aug 2019 11:08:59 +0200 (CEST) Received: (qmail 96961 invoked by uid 500); 14 Aug 2019 09:08:59 -0000 Mailing-List: contact dev-help@singa.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@singa.incubator.apache.org Delivered-To: mailing list dev@singa.incubator.apache.org Received: (qmail 96951 invoked by uid 99); 14 Aug 2019 09:08:59 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Aug 2019 09:08:59 +0000 From: GitBox To: dev@singa.apache.org Subject: [GitHub] [incubator-singa] nudles commented on a change in pull request #496: SINGA-474 Mean operator Message-ID: <156577373900.4789.11350503042313198950.gitbox@gitbox.apache.org> Date: Wed, 14 Aug 2019 09:08:59 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit nudles commented on a change in pull request #496: SINGA-474 Mean operator URL: https://github.com/apache/incubator-singa/pull/496#discussion_r313776492 ########## 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: use inplace addition. like x+= l[i] ---------------------------------------------------------------- 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