Exemplo n.º 1
0
    def set_wages(self, wages):
        shapes = list([l.W.shape for l in self.layers[1:]])
        packed = list(util.wrap_matrix(wages, shapes))

        assert len(packed) == len(self.layers) - 1

        for i, layer in enumerate(self.layers[1:]):
            layer.W = packed[i]
Exemplo n.º 2
0
    def test_wrap(self):
        flat = np.array(np.linspace(1, 26, 26))
        nest = util.wrap_matrix(flat, [(2, 3), (4, 5)])
        a = np.array([[1, 2, 3], [4, 5, 6]])
        b = np.array([[7, 8, 9, 10, 11],
                      [12, 13, 14, 15, 16],
                      [17, 18, 19, 20, 21],
                      [22, 23, 24, 25, 26]])

        r = [x for x in nest]

        assert np.array_equal(r[0], a)
        assert np.array_equal(r[1], b)
Exemplo n.º 3
0
 def set_wages(self, wages):
     self.W1, self.W2 = util.wrap_matrix(wages, [self.W1.shape, self.W2.shape])