test_optimizer.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:ngraph 作者: NervanaSystems 项目源码 文件源码
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.ones_like(weights)

        if self.velocity is None:
            self.velocity = np.zeros_like(weights)

        gradient = - input_data.mean(axis=1)

        self.state[:] = self.decay_rate * self.state + \
            (1.0 - self.decay_rate) * np.square(gradient)

        self.velocity = self.velocity * self.momentum + \
            self.learning_rate * gradient / np.sqrt(self.state + self.epsilon) + \
            self.learning_rate * self.wdecay * weights
        weights[:] = weights - self.velocity

        return weights
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号