Here is part of get_updates
code from SGD
from keras
(source)
moments = [K.zeros(shape) for shape in shapes]
self.weights = [self.iterations] + moments
for p, g, m in zip(params, grads, moments):
v = self.momentum * m - lr * g # velocity
self.updates.append(K.update(m, v))
Observation:
Since moments
variable is a list of zeros tensors. Each m
in the for loop
is a zero tensor with the shape of p
. Then the self.momentum * m
, at the first line of the loop, is just a scalar multiply by zero tensor which result a zero tensor.
Question
What am I missing here?