def check_forward(self, x_data):
x = chainer.Variable(x_data)
y = functions.clipped_relu(x, self.z)
self.assertEqual(y.data.dtype, self.dtype)
y_expect = self.x.copy()
for i in numpy.ndindex(self.x.shape):
if self.x[i] < 0:
y_expect[i] = 0
elif self.x[i] > self.z:
y_expect[i] = self.z
gradient_check.assert_allclose(y_expect, y.data)
评论列表
文章目录