【问题标题】:L2 matrix rowwise normalization gradientL2矩阵行归一化梯度
【发布时间】:2016-03-02 01:18:32
【问题描述】:

我正在尝试为卷积神经网络实现 L2 范数层,但我陷入了后向传播:

def forward(self, inputs):
    x, = inputs
    self._norm = np.expand_dims(np.linalg.norm(x, ord=2, axis=1), axis=1)
    z = np.divide(x, self._norm)
    return z,

def backward(self, inputs, grad_outputs):
    x, = inputs
    gz, = grad_outputs
    gx = None # how to compute gradient here?
    return gx,

如何计算gx? 我的第一个猜测是

gx = - gz * x / self._norm**2

但这个似乎是错误的。

【问题讨论】:

    标签: python numpy neural-network deep-learning backpropagation


    【解决方案1】:

    正确答案是

    gx = np.divide(gz, self._norm)
    

    【讨论】:

      猜你喜欢
      • 2016-07-25
      • 1970-01-01
      • 1970-01-01
      • 2018-07-04
      • 2017-10-15
      • 2015-04-10
      • 2017-02-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多