【发布时间】: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