예제 #1
0
 def test_slice_2D(self):
     data = np.random.randn(2, 3)
     parameter = Parameter(shape=(2, 3), init_weight=data)
     out = parameter.slice(0, 0, 2)
     model = Model(input=parameter, output=out)
     result = model.forward(data)
     np.testing.assert_almost_equal(result, data[0:2], decimal=5)
예제 #2
0
 def test_sum_2D(self):
     data = np.random.randn(2, 3)
     parameter = Parameter(shape=(2, 3), init_weight=data)
     out = autograd.sum(parameter, axis=0)
     model = Model(input=parameter, output=out)
     result = model.forward(data)
     np.testing.assert_almost_equal(result, data.sum(axis=0), decimal=5)
예제 #3
0
 def test_unsqueeze_1D(self):
     data = np.random.randn(4, )
     parameter = Parameter(shape=(4, ), init_weight=data)
     out = autograd.expand_dims(parameter, axis=0)
     model = Model(input=parameter, output=out)
     result = model.forward(data)
     np.testing.assert_almost_equal(result,
                                    np.expand_dims(data, axis=0),
                                    decimal=5)