You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/06/11 04:02:06 UTC

[GitHub] eric-haibin-lin commented on a change in pull request #11223: Allow specifying AdaGrad initial accumulator value

eric-haibin-lin commented on a change in pull request #11223: Allow specifying AdaGrad initial accumulator value
URL: https://github.com/apache/incubator-mxnet/pull/11223#discussion_r194288620
 
 

 ##########
 File path: python/mxnet/optimizer.py
 ##########
 @@ -1091,14 +1091,22 @@ class AdaGrad(Optimizer):
     ----------
     eps: float, optional
         Small value to avoid division by 0.
+    initial_accumulator_value: float, default 0
+        The Adagrad state is initially set to this value.
 
     """
-    def __init__(self, eps=1e-7, **kwargs):
+    def __init__(self, eps=1e-7, initial_accumulator_value=0, **kwargs):
         super(AdaGrad, self).__init__(**kwargs)
         self.float_stable_eps = eps
+        self.initial_accumulator_value = initial_accumulator_value
 
     def create_state(self, index, weight):
-        return zeros(weight.shape, weight.context, stype=weight.stype)  # history
+        # history
+        if self.initial_accumulator_value == 0:
+            return zeros(weight.shape, weight.context, stype=weight.stype)
 
 Review comment:
   What about 
   ```
   history = zeros(weight.shape, weight.context, stype=weight.stype)
   if self.initial_accumulator_value:
       history[:] = self.initial_accumulator_value
   ```
   This way the stype of history doesn't change
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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