Beispiel #1
0
def point_test_grad_impl():
    # check gradient implementation
    rng = nprs(42)
    test_ob = rng.uniform(size=(4, ))
    test_act = rng.uniform(size=(4, ))
    test_theta = rng.uniform(size=(4, 5))
    # Check that the shape matches
    assert point_get_grad_logp_action(test_theta, test_ob,
                                      test_act).shape == test_theta.shape
    gradient_check(
        lambda x: point_get_logp_action(x.reshape(test_theta.shape), test_ob,
                                        test_act),
        lambda x: point_get_grad_logp_action(x.reshape(test_theta.shape),
                                             test_ob, test_act).flatten(),
        test_theta.flatten())
def point_test_grad_impl():
    # check gradient implementation
    rng = nprs(42)
    test_ob = rng.uniform(size=(4,))
    test_act = rng.uniform(size=(4,))
    test_theta = rng.uniform(size=(4, 5))
    # Check that the shape matches
    assert point_get_grad_logp_action(
        test_theta, test_ob, test_act).shape == test_theta.shape
    gradient_check(
        lambda x: point_get_logp_action(
            x.reshape(test_theta.shape), test_ob, test_act),
        lambda x: point_get_grad_logp_action(
            x.reshape(test_theta.shape), test_ob, test_act).flatten(),
        test_theta.flatten()
    )