Example #1
0
def test_dv_finite_space_model(finite_space_model, one_point_design, true_eig):
    pyro.set_rng_seed(42)
    pyro.clear_param_store()
    donsker_varadhan_eig(
        finite_space_model,
        one_point_design,
        "y",
        "theta",
        num_samples=100,
        num_steps=250,
        T=dv_critic,
        optim=optim.Adam({"lr": 0.1}),
    )
    estimated_eig = donsker_varadhan_eig(
        finite_space_model,
        one_point_design,
        "y",
        "theta",
        num_samples=100,
        num_steps=250,
        T=dv_critic,
        optim=optim.Adam({"lr": 0.01}),
        final_num_samples=2000,
    )
    assert_equal(estimated_eig, true_eig, prec=1e-2)
Example #2
0
def test_dv_linear_model(linear_model, one_point_design):
    pyro.set_rng_seed(42)
    pyro.clear_param_store()
    donsker_varadhan_eig(
        linear_model,
        one_point_design,
        "y",
        "w",
        num_samples=100,
        num_steps=500,
        T=dv_critic,
        optim=optim.Adam({"lr": 0.1}),
    )
    estimated_eig = donsker_varadhan_eig(
        linear_model,
        one_point_design,
        "y",
        "w",
        num_samples=100,
        num_steps=650,
        T=dv_critic,
        optim=optim.Adam({"lr": 0.001}),
        final_num_samples=2000,
    )
    expected_eig = linear_model_ground_truth(linear_model, one_point_design, "y", "w")
    assert_equal(estimated_eig, expected_eig, prec=5e-2)