def setUp(self):
in_size = numpy.prod(self.in_shape)
self.link = links.Linear(in_size, self.out_size)
W = self.link.W.data
W[...] = numpy.random.uniform(-1, 1, W.shape)
b = self.link.b.data
b[...] = numpy.random.uniform(-1, 1, b.shape)
self.link.zerograds()
self.W = W.copy() # fixed on CPU
self.b = b.copy() # fixed on CPU
x_shape = (4,) + self.in_shape
self.x = numpy.random.uniform(-1, 1, x_shape).astype(numpy.float32)
self.gy = numpy.random.uniform(
-1, 1, (4, self.out_size)).astype(numpy.float32)
self.y = self.x.reshape(4, -1).dot(W.T) + b
评论列表
文章目录