def __init__(self, optimizer): self.model = FunctionSet(l=Linear(self.UNIT_NUM, 2)) self.optimizer = optimizer # true parameters self.w = np.random.uniform(-1, 1, (self.UNIT_NUM, 1)).astype(np.float32) self.b = np.random.uniform(-1, 1, (1, )).astype(np.float32)
def setUp(self): self.func = Linear(3, 2) self.func.W = numpy.random.uniform(-1, 1, self.func.W.shape).astype( numpy.float32) self.func.b = numpy.random.uniform(-1, 1, self.func.b.shape).astype( numpy.float32) self.func.gW.fill(0) self.func.gb.fill(0) self.W = self.func.W.copy() # fixed on CPU self.b = self.func.b.copy() # fixed on CPU self.x = numpy.random.uniform(-1, 1, (4, 3)).astype(numpy.float32) self.gy = numpy.random.uniform(-1, 1, (4, 2)).astype(numpy.float32) self.y = self.x.dot(self.func.W.T) + self.func.b
def setUp(self): self.fs = FunctionSet(a=Linear(3, 2), b=Linear(3, 2))