Ejemplo n.º 1
0
 def test_create_output_view_with_single_sample(self):
     l = pw.create_layer("LstmLayer", 3, 7)
     im = pw.Matrix(l.out_size)
     I = l.create_output_view(im)
     self.assertIsNotNone(I)
     self.assertEqual(len(I), 7)
     self.assertEqual(I.shape(), (1, 1, 7))
Ejemplo n.º 2
0
 def test_create_input_view_with_single_sample(self):
     l = pw.create_layer("ForwardLayer", 3, 7)
     im = pw.Matrix(l.in_size)
     I = l.create_input_view(im)
     self.assertIsNotNone(I)
     self.assertEqual(len(I), 3)
     self.assertEqual(I.shape(), (1, 1, 3))
Ejemplo n.º 3
0
 def test_create_input_view_with_single_sample(self):
     l = pw.create_layer("ForwardLayer", 3, 7)
     im = pw.Matrix(l.in_size)
     I = l.create_input_view(im)
     self.assertIsNotNone(I)
     self.assertEqual(len(I), 3)
     self.assertEqual(I.shape(), (1, 1, 3))
Ejemplo n.º 4
0
 def test_create_output_view_with_1d_buffer(self):
     l = pw.create_layer("LstmLayer", 3, 7)
     t = 9
     b = 5
     im = pw.Matrix(l.get_output_buffer_size(t, b))
     I = l.create_output_view(im, t, b)
     self.assertIsNotNone(I)
     self.assertEqual(len(I), 7 * t * b)
     self.assertEqual(I.shape(), (t, b, 7))
Ejemplo n.º 5
0
 def test_create_input_view_with_3d_buffer(self):
     l = pw.create_layer("LstmLayer", 3, 7)
     t = 9
     b = 5
     im = pw.Matrix(t, b, l.in_size)
     I = l.create_input_view(im, t, b)
     self.assertIsNotNone(I)
     self.assertEqual(len(I), 3 * t * b)
     self.assertEqual(I.shape(), (t, b, 3))
Ejemplo n.º 6
0
 def test_create_output_view_with_3d_buffer(self):
     l = pw.create_layer("ForwardLayer", 3, 7)
     t = 9
     b = 5
     im = pw.Matrix(t, b, l.out_size)
     I = l.create_output_view(im, t, b)
     self.assertIsNotNone(I)
     self.assertEqual(len(I), 7 * t * b)
     self.assertEqual(I.shape(), (t, b, 7))
Ejemplo n.º 7
0
 def test_create_output_view_with_3d_buffer(self):
     l = pw.create_layer("ForwardLayer", 3, 7)
     t = 9
     b = 5
     im = pw.Matrix(t, b, l.out_size)
     I = l.create_output_view(im, t, b)
     self.assertIsNotNone(I)
     self.assertEqual(len(I), 7 * t * b)
     self.assertEqual(I.shape(), (t, b, 7))
Ejemplo n.º 8
0
    def test_forward_pass(self):
        t = 2  # time
        b = 1  # batches
        n = 5  # input size
        m = 3  # output size

        l = pw.create_layer("LstmLayer", n, m)
        X = pw.Matrix(t, b, n)
        Y = pw.Matrix(t, b, m)
        wm = pw.Matrix(1, 1, l.get_parameter_size())
        W = l.create_param_view(wm)
        im = pw.Matrix(t, b, l.get_fwd_state_size(t, b))
        I = l.create_fwd_state(im, t, b)
        l.forward(W, I, X, Y, False)
Ejemplo n.º 9
0
 def test_in_out_sizes_match(self):
     sizes = [(1, 1), (1, 9), (9, 1), (9, 9), (3, 7)]
     for n, m in sizes:
         l = pw.create_layer("LstmLayer", n, m)
         self.assertEqual(l.in_size, n)
         self.assertEqual(l.out_size, m)
Ejemplo n.º 10
0
 def test_create_fwd_state(self):
     l = pw.create_layer("LstmLayer", 3, 7)
     im = pw.Matrix(l.get_fwd_state_size())
     I = l.create_fwd_state(im)
     self.assertIsNotNone(I)
Ejemplo n.º 11
0
 def test_create_param_view(self):
     l = pw.create_layer("LstmLayer", 3, 7)
     wm = pw.Matrix(l.get_parameter_size())
     W = l.create_param_view(wm)
     self.assertIsNotNone(W)
Ejemplo n.º 12
0
 def test_fwd_state_size(self):
     sizes = [(1, 1), (1, 9), (9, 1), (9, 9), (3, 7)]
     for n, m in sizes:
         l = pw.create_layer("LstmLayer", n, m)
         fwd_state_size = l.get_fwd_state_size()
         self.assertGreaterEqual(fwd_state_size, m)
Ejemplo n.º 13
0
 def test_param_size(self):
     sizes = [(1, 1), (1, 9), (9, 1), (9, 9), (3, 7)]
     for n, m in sizes:
         l = pw.create_layer("LstmLayer", n, m)
         param_size = l.get_parameter_size()
         self.assertGreaterEqual(param_size, n * m)