def __call__(self, input_data, weights):
'''
input_data in this case is a numpy array with batch_size on axis 1
and weights is a matrix with 1 column
'''
if self.state is None:
self.state = np.zeros_like(weights)
gradient = - input_data.mean(axis=1)
self.state[:] = self.state + np.square(gradient)
weights[:] = weights \
- gradient * self.learning_rate / (np.sqrt(self.state + self.epsilon))
return weights
评论列表
文章目录