You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by jx...@apache.org on 2018/05/10 17:55:50 UTC

[incubator-mxnet] branch master updated: prevent setting grad_req for Constant (#10869)

This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
     new 1014c94  prevent setting grad_req for Constant (#10869)
1014c94 is described below

commit 1014c9479421d25b6122af9e58e8a978e2c17598
Author: Sheng Zha <sz...@users.noreply.github.com>
AuthorDate: Thu May 10 10:55:44 2018 -0700

    prevent setting grad_req for Constant (#10869)
    
    * prevent setting grad_req for Constant
    
    * update
    
    * add ignore new value
---
 python/mxnet/gluon/parameter.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/python/mxnet/gluon/parameter.py b/python/mxnet/gluon/parameter.py
index a3a1e32..320b376 100644
--- a/python/mxnet/gluon/parameter.py
+++ b/python/mxnet/gluon/parameter.py
@@ -503,6 +503,17 @@ class Constant(Parameter):
         s = 'Constant {name} (shape={shape}, dtype={dtype})'
         return s.format(name=self.name, shape=self.shape, dtype=self.dtype)
 
+    @property
+    def grad_req(self):
+        return 'null'
+
+    @grad_req.setter
+    def grad_req(self, req):
+        if req != 'null':
+            warnings.warn('Constant parameter "{}" does not support '
+                          'grad_req other than "null", and new value "{}" '
+                          'is ignored.'.format(self.name, req))
+
 
 class ParameterDict(object):
     """A dictionary managing a set of parameters.

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.