Example #1
0
def test_rff_feature_map_comp_theano_execute():
    if not theano_available:
        raise SkipTest("Theano not available.")
    
    D = 2
    x = np.random.randn(D)
    m = 10
    sigma = 1.
    omega, u = rff_sample_basis(D, m, sigma)
    
    for i in range(m):
        rff_feature_map_comp_theano(x, omega[:, i], u[i])
Example #2
0
def test_rff_feature_map_comp_theano_execute():
    if not theano_available:
        raise SkipTest("Theano not available.")

    D = 2
    x = np.random.randn(D)
    m = 10
    sigma = 1.
    omega, u = rff_sample_basis(D, m, sigma)

    for i in range(m):
        rff_feature_map_comp_theano(x, omega[:, i], u[i])
Example #3
0
def test_rff_feature_map_comp_theano_result_equals_manual():
    if not theano_available:
        raise SkipTest("Theano not available.")
    
    D = 2
    x = np.random.randn(D)
    m = 10
    sigma = 1.
    omega, u = rff_sample_basis(D, m, sigma)
    
    phi_manual = rff_feature_map_single(x, omega, u)
    for i in range(m):
        # phi_manual is a monte carlo average, so have to normalise by np.sqrt(m) here
        phi = rff_feature_map_comp_theano(x, omega[:, i], u[i]) / np.sqrt(m)
        assert_close(phi, phi_manual[i])
Example #4
0
def test_rff_feature_map_comp_theano_result_equals_manual():
    if not theano_available:
        raise SkipTest("Theano not available.")

    D = 2
    x = np.random.randn(D)
    m = 10
    sigma = 1.
    omega, u = rff_sample_basis(D, m, sigma)

    phi_manual = rff_feature_map_single(x, omega, u)
    for i in range(m):
        # phi_manual is a monte carlo average, so have to normalise by np.sqrt(m) here
        phi = rff_feature_map_comp_theano(x, omega[:, i], u[i]) / np.sqrt(m)
        assert_close(phi, phi_manual[i])