From dev-return-5115-archive-asf-public=cust-asf.ponee.io@singa.apache.org Sun Apr 12 06:29:11 2020 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 6AEA5180608 for ; Sun, 12 Apr 2020 08:29:11 +0200 (CEST) Received: (qmail 89388 invoked by uid 500); 12 Apr 2020 06:29:10 -0000 Mailing-List: contact dev-help@singa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@singa.apache.org Delivered-To: mailing list dev@singa.apache.org Received: (qmail 89378 invoked by uid 99); 12 Apr 2020 06:29:10 -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; Sun, 12 Apr 2020 06:29:10 +0000 From: GitBox To: dev@singa.apache.org Subject: [GitHub] [singa] XJDKC commented on issue #674: Autograd Layer constructor Message-ID: <158667295056.2322.14413232932311702897.gitbox@gitbox.apache.org> References: In-Reply-To: Date: Sun, 12 Apr 2020 06:29:10 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit XJDKC commented on issue #674: Autograd Layer constructor URL: https://github.com/apache/singa/issues/674#issuecomment-612571097 > > > > I think it's not an issue. When we use the computational graph, initialization operations won't be buffered since we just need to execute them once. For these operations, I just execute them immediately instead of buffering them into the graph at present. So before running the entire graph, all parameter tensors will be initialized. > > > > > > > > > but you need to identify the operations for initialization.. how to tell if an operation is for initialization or not? > > > > > > At present, if the operations are for initialization, they are likely to be in the constructor function. So I just turn on the graph before calling the **call** function of Layer and forward and backward function of Operation. So all the initialization operations in the constructor will be executed immediately. For those initialization operations in the functions I mentioned above, I turn off the buffer before calling them. Like this, [turn off graph](https://github.com/apache/singa/blob/master/python/singa/opt.py#L155). > > @XJDKC Yes, that' why prof. suggest add the wrapper to it: > > ``` > I think it would be better to define a new function to wrap these lines: > def execute_once(fn): > get flag > disable graph > fn() > set flag > ``` Yes, we can use a decorator to achieve it. ---------------------------------------------------------------- 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