def check_forward(self, x_data):
x = chainer.Variable(x_data)
y = functions.local_response_normalization(x)
self.assertEqual(y.data.dtype, self.dtype)
y_data = cuda.to_cpu(y.data)
# Naive implementation
y_expect = numpy.zeros_like(self.x)
for n, c, h, w in numpy.ndindex(self.x.shape):
s = 0
for i in six.moves.range(max(0, c - 2), min(7, c + 2)):
s += self.x[n, i, h, w] ** 2
denom = (2 + 1e-4 * s) ** .75
y_expect[n, c, h, w] = self.x[n, c, h, w] / denom
gradient_check.assert_allclose(
y_expect, y_data, **self.check_forward_optionss)
test_local_response_normalization.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录