def setUp(self): self.x_shape = (4, 3, 2) self.dtype = numpy.float32 self.link = links.Swish(None) self.link.cleargrads() self.x = numpy.random.uniform(-1, 1, self.x_shape).astype(self.dtype) self.gy = numpy.random.uniform(-1, 1, self.x_shape).astype(self.dtype)
def setUp(self): self.x_shape = (4, 3, 2) self.dtype = numpy.float32 self.link = links.Swish(()) beta = self.link.beta.data beta[...] = numpy.random.uniform(-1, 1, beta.shape) self.link.cleargrads() self.x = numpy.random.uniform(-1, 1, self.x_shape).astype(self.dtype) self.gy = numpy.random.uniform(-1, 1, self.x_shape).astype(self.dtype)
def __init__(self, n_in=75, n_units=500, n_units2=400, n_out=75, train=True): super(LSTM, self).__init__() with self.init_scope(): self.l1 = L.LSTM( in_size=n_in, out_size=n_units, lateral_init=chainer.initializers.Normal(scale=0.01)) self.l2 = L.Linear( in_size=n_units, out_size=n_out, initialW=chainer.initializers.Normal(scale=0.01)) self.l3 = L.Swish(beta_shape=n_out) self.train = train
def __init__(self, function, inputs, outputs): super(ConvertSwish, self).__init__() with self.init_scope(): self.f = L.Swish(beta_shape=function.params['beta'].shape, beta_init=function.params['beta'])