Ejemplo n.º 1
0
 def test_cross_validation_run_01(self):
     np.random.seed(42)
     inputs = np.random.uniform(-1, 1, 15).reshape(5, -1)
     outputs = np.random.uniform(0, 5, 10).reshape(5, -1)
     gradients = np.random.uniform(-1, 1, 30).reshape(5, 2, 3)
     ss = ActiveSubspaces(dim=1, method='exact')
     csv = CrossValidation(inputs=inputs,
                           outputs=outputs,
                           gradients=gradients,
                           folds=2,
                           subspace=ss)
     true_value = (8.91180601306311, 6.806790947903309)
     np.testing.assert_array_almost_equal(csv.run(), true_value)
Ejemplo n.º 2
0
 def test_cross_validation_run_01(self):
     np.random.seed(42)
     inputs = np.random.uniform(-1, 1, 15).reshape(5, -1)
     outputs = np.random.uniform(0, 5, 10).reshape(5, -1)
     gradients = np.random.uniform(-1, 1, 30).reshape(5, 2, 3)
     ss = ActiveSubspaces()
     csv = CrossValidation(inputs=inputs,
                           outputs=outputs,
                           gradients=gradients,
                           folds=2,
                           subspace=ss)
     true_value = (8.186941403385733, 6.081926389368339)
     np.testing.assert_array_almost_equal(csv.run(), true_value)
Ejemplo n.º 3
0
 def test_cross_validation_run_02(self):
     np.random.seed(42)
     inputs = np.random.uniform(-1, 1, 10).reshape(5, 2)
     outputs = np.random.uniform(0, 5, 10).reshape(5, 2)
     gradients = np.random.uniform(-1, 1, 20).reshape(5, 2, 2)
     fm = FeatureMap(distr='laplace',
                     bias=np.random.uniform(-1, 1, 3),
                     input_dim=2,
                     n_features=3,
                     params=np.zeros(1),
                     sigma_f=outputs.var())
     ss = KernelActiveSubspaces(dim=1, feature_map=fm)
     csv = CrossValidation(inputs=inputs,
                           outputs=outputs,
                           gradients=gradients,
                           folds=2,
                           subspace=ss)
     true_value = (2.26333743325053, 0.43902733603381605)
     np.testing.assert_array_almost_equal(csv.run(), true_value)