Exemple #1
0
 def test_compute_fmap_jac(self):
     np.random.seed(42)
     fm = FeatureMap(distr='laplace',
                     bias=np.ones((1, 3)),
                     input_dim=2,
                     n_features=3,
                     params=[0.8, 2.3],
                     sigma_f=0.9)
     inputs = np.random.uniform(size=(5, 2))
     fmap_jac = fm.compute_fmap_jac(inputs=inputs)
     true_value = np.array([[[-3.53084308, 3.923392],
                             [-2.20214773, 0.77718418],
                             [-0.94652067, -0.93418587]],
                            [[2.56578301, -2.85103934],
                             [-0.9835101, 0.34710137],
                             [-0.95558954, -0.94313656]],
                            [[4.30961695, -4.7887477],
                             [-2.36809012, 0.83574874],
                             [0.56400016, 0.55665027]],
                            [[2.82613179, -3.14033295],
                             [-0.43435979, 0.15329469],
                             [-0.43037806, -0.42476949]],
                            [[3.84444395, -4.2718581],
                             [-2.01936794, 0.71267736],
                             [-0.93447546, -0.92229763]]])
     np.testing.assert_array_almost_equal(true_value, fmap_jac)
Exemple #2
0
 def test_compute_fmap_jac(self):
     np.random.seed(42)
     fm = FeatureMap(distr='laplace',
                     bias=np.ones((1, 3)),
                     input_dim=2,
                     n_features=3,
                     params=[0.8, 2.3],
                     sigma_f=0.9)
     inputs = np.random.uniform(size=(5, 2))
     fmap_jac = fm.compute_fmap_jac(inputs=inputs)
     true_value = np.array([[[1.53620402, -1.35337581],
                             [-0.40223905, 0.31509425],
                             [-0.03915164, -0.03881686]],
                            [[0.86249731, -0.75984894],
                             [-0.60576495, 0.4745264],
                             [-0.04318837, -0.04281907]],
                            [[1.52824153, -1.34636096],
                             [-0.5508609, 0.43151728],
                             [0.4047367, 0.40127589]],
                            [[0.62961265, -0.55468058],
                             [-0.28380577, 0.22231945],
                             [0.15175034, 0.15045276]],
                            [[1.63406118, -1.4395867],
                             [-0.55448363, 0.43435515],
                             [-0.03243032, -0.03215301]]])
     np.testing.assert_array_almost_equal(true_value, fmap_jac)