zhanghang1989 commented on a change in pull request #16053: Fixes #15543
URL: https://github.com/apache/incubator-mxnet/pull/16053#discussion_r320903141
 
 

 ##########
 File path: tests/python/unittest/test_optimizer.py
 ##########
 @@ -399,11 +395,7 @@ def update(self, index, weight, grad, state):
             if self.momentum == 0.0:
                 weight32[:] += -lr * (grad32 + wd * weight32)
             else:
-                mom[:] *= self.momentum
-                weight32[:] -= self.momentum * mom[:]
-                grad32 += wd * weight32
-                grad32 *= lr
-                weight32[:] -= (self.momentum + 1) * grad32
+                weight32[:] += (self.momentum**2 * mom) - 
lr*(self.momentum+1)*(grad32 + wd*weight32)
 
 Review comment:
   Should multiply `lr` for the first term. `weight32[:] += 
lr*(self.momentum**2 * mom) - lr*(self.momentum+1)*(grad32 + wd*weight32)`

----------------------------------------------------------------
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