examples/learn_search_space/__init__.py
def rej_sampling_ellips_space(matrix_a, vector_b, curr_task):
    """Reject sample from ellipsoidal search space example"""
    hyper_param_dim = vector_b.shape[0]
    _, curr_bound = rep_task([], curr_task)

    is_feasible = False
    while not is_feasible:
        mean = np.zeros(hyper_param_dim)
        cov = np.eye(hyper_param_dim)
        z = np.random.multivariate_normal(mean, cov)
        r = np.random.random()
        scale = np.power(r, 1.0 / hyper_param_dim) / np.linalg.norm(z)
        t = scale * z
        x = np.mat(np.linalg.inv(matrix_a)) * np.matrix.transpose(np.mat(t - vector_b))
        x = np.array(x).ravel()
        diff = curr_bound - np.tile(x, (2, 1))
        if np.all(diff[0, :] <= 0) and np.all(diff[1, :] >= 0):  # x in curr search space
            is_feasible = True

    # x is in the same order as curr_task representation
    return x
Reject sample from ellipsoidal search space example
Reject sample from ellipsoidal search space example
Reject sample from ellipsoidal search space example
def rej_sampling_ellips_space(matrix_a, vector_b, curr_task):
    hyper_param_dim = vector_b.shape[0]
    _, curr_bound = rep_task([], curr_task)
    is_feasible = False
    while not is_feasible:
        mean = np.zeros(hyper_param_dim)
        cov = np.eye(hyper_param_dim)
        z = np.random.multivariate_normal(mean, cov)
        r = np.random.random()
        scale = np.power(r, 1.0 / hyper_param_dim) / np.linalg.norm(z)
        t = scale * z
        x = np.mat(np.linalg.inv(matrix_a)) * np.matrix.transpose(np.mat(t - vector_b))
        x = np.array(x).ravel()
        diff = curr_bound - np.tile(x, (2, 1))
        if np.all(diff[0, :] <= 0) and np.all(diff[1, :] >= 0):  
            is_feasible = True
    return x
def rej_sampling_ellips_space ( matrix_a , vector_b , curr_task ) : hyper_param_dim = vector_b . shape [ 0 ] _ , curr_bound = rep_task ( [ ] , curr_task ) is_feasible = False while not is_feasible : mean = np . zeros ( hyper_param_dim ) cov = np . eye ( hyper_param_dim ) z = np . random . multivariate_normal ( mean , cov ) r = np . random . random ( ) scale = np . power ( r , 1.0 / hyper_param_dim ) / np . linalg . norm ( z ) t = scale * z x = np . mat ( np . linalg . inv ( matrix_a ) ) * np . matrix . transpose ( np . mat ( t - vector_b ) ) x = np . array ( x ) . ravel ( ) diff = curr_bound - np . tile ( x , ( 2 , 1 ) ) if np . all ( diff [ 0 , : ] <= 0 ) and np . all ( diff [ 1 , : ] >= 0 ) : is_feasible = True return x
Reject sample from ellipsoidal search space example
Reject sample from ellipsoidal search space example
"""Reject sample from ellipsoidal search space example""" # x in curr search space # x is in the same order as curr_task representation
matrix_a
vector_b
curr_task