Ejemplo n.º 1
0
 def setUp(self):
     in_size, out_size = 10, 8
     self.link = links.StatefulZoneoutLSTM(in_size, out_size)
     self.c = chainer.Variable(
         numpy.random.uniform(-1, 1, (1, out_size)).astype(numpy.float32))
     self.h = chainer.Variable(
         numpy.random.uniform(-1, 1, (1, out_size)).astype(numpy.float32))
Ejemplo n.º 2
0
 def __init__(self, n_in, n_hid, n_out):
     links = []
     links.append(
         L.StatefulZoneoutLSTM(n_in, n_hid, c_ratio=.05, h_ratio=.05))
     links.append(L.Linear(None, n_out))
     self.n_out = n_out
     super(RNN, self).__init__(*links)
 def __init__(self, n_units, n_out, layers=2, c_ratio=0.5, h_ratio=0.5):
     super(ZoneoutLSTM, self).__init__()
     self.layers = layers
     with self.init_scope():
         for l in range(layers):
             setattr(self, "layer_{}".format(l),
                     L.StatefulZoneoutLSTM(None, n_units, c_ratio, h_ratio))
         self.out = L.Linear(None, n_out)
Ejemplo n.º 4
0
    def setUp(self):
        self.link = links.StatefulZoneoutLSTM(self.in_size, self.out_size,
                                              c_ratio=self.c_ratio,
                                              h_ratio=self.h_ratio)
        upward = self.link.upward.W.data
        upward[...] = numpy.random.uniform(-1, 1, upward.shape)
        lateral = self.link.lateral.W.data
        lateral[...] = numpy.random.uniform(-1, 1, lateral.shape)

        c_shape = (4, self.out_size)
        h_shape = (4, self.out_size)
        x_shape = (4, self.in_size)
        gy_shape = (4, self.out_size)
        self.c = numpy.zeros(c_shape).astype(numpy.float32)
        self.h = numpy.zeros(h_shape).astype(numpy.float32)
        self.x = numpy.random.uniform(-1, 1, x_shape).astype(numpy.float32)
        self.gy = numpy.random.uniform(-1, 1, gy_shape).astype(numpy.float32)
Ejemplo n.º 5
0
 def setUp(self):
     in_size, out_size = 10, 8
     self.link = links.StatefulZoneoutLSTM(in_size, out_size)