예제 #1
0
            approx.random_fn(no_rand=True)
            approx.random_fn(no_rand=False)
            approx.histogram_logp.eval()

    def test_init_from_noize(self):
        with models.multidimensional_model()[1]:
            approx = Empirical.from_noise(100)
            assert approx.histogram.eval().shape == (100, 6)


_model = models.simple_model()[1]
with _model:
    pm.Potential('pot', tt.ones((10, 10)))
    _advi = ADVI()
    _fullrank_advi = FullRankADVI()
    _svgd = SVGD()


@pytest.mark.parametrize(
    ['method', 'kwargs', 'error'],
    [('undefined', dict(), KeyError), (1, dict(), TypeError),
     (_advi, dict(start={}), None), (_fullrank_advi, dict(), None),
     (_svgd, dict(), None), ('advi', dict(), None),
     ('advi->fullrank_advi', dict(frac=.1), None),
     ('advi->fullrank_advi', dict(frac=1), ValueError),
     ('fullrank_advi', dict(), None), ('svgd', dict(), None),
     ('svgd', dict(start={}), None),
     ('svgd', dict(local_rv={_model.free_RVs[0]: (0, 1)}), ValueError)])
def test_fit(method, kwargs, error):
    with _model:
        if error is not None:
예제 #2
0
def test_from_empirical(another_simple_model):
    with another_simple_model:
        emp = Empirical.from_noise(1000)
        svgd = SVGD.from_empirical(emp)
        svgd.fit(20)
예제 #3
0
def test_from_empirical(another_simple_model):
    with another_simple_model:
        emp = Empirical.from_noise(1000)
        svgd = SVGD.from_empirical(emp)
        svgd.fit(20)