dora/regressors/gp/kernel.py
def non_stationary(x_p, x_q, params):
    """ Implementation of Paciorek's kernel where length scale is defined as
    a continuous function L(x), and computed by operations on L(x1) and L(x2)

    Note - we globally apply ARD scaling, then inside the scaled space apply an
    isotropic non-stationary treatment according to L(x)

    Arguments:
     x_p, x_q : n*d x-values
     params(list): [ (d,) np array of length-scale multipliers scaling the...,
                     function L(x) ]

    """
    assert(x_p.ndim == 2)
    if x_q is None:
        # Just want the magnitude to be evaluated - its always 1 :)
        return np.ones(x_p.shape[0])

    LS_mult, LS_func = params  # unpack parameters
    dims = x_p.shape[1]

    ls_p = LS_func(x_p)
    ls_q = LS_func(x_q)

    if dims > 1:
        assert(LS_mult.shape[0] == dims)
        assert(len(LS_mult.shape) == 1)

    assert(len(ls_p.shape) == 1)

    ls_p = ls_p[:, np.newaxis]
    ls_q = ls_q[:, np.newaxis]

    sig_mult = LS_mult**2
    sig_p = ls_p**2
    sig_q = ls_q**2

    sig_avg = 0.5*(sig_p + sig_q.T)
    ls_avg = sig_avg**0.5

    # In the diagonal [axis aligned] case, the determinants of the length
    # scales are simply their products
    det_sig_mult = np.prod(sig_mult)
    # todo(AL) can probably remove det_sig_mult altogether as it should cancel
    dets_p = det_sig_mult * sig_p**dims
    dets_q = det_sig_mult * sig_q**dims
    dets_avg = det_sig_mult * sig_avg**dims

    # Compute non-stationary kernel
    gain = np.sqrt(np.sqrt(dets_p * dets_q.T) / dets_avg)

    return gain * np.exp(-cdist(x_p/LS_mult, x_q/LS_mult, 'sqeuclidean')
                         / ls_avg**2)
 Implementation of Paciorek's kernel where length scale is defined as
    a continuous function L(x), and computed by operations on L(x1) and L(x2)

    Note - we globally apply ARD scaling, then inside the scaled space apply an
    isotropic non-stationary treatment according to L(x)

    Arguments:
     x_p, x_q : n*d x-values
     params(list): [ (d,) np array of length-scale multipliers scaling the...,
                     function L(x) ]

    
Implementation of Paciorek's kernel where length scale is defined as
a continuous function L(x), and computed by operations on L(x1) and L(x2)

we globally apply ARD scaling, then inside the scaled space apply an
isotropic non-stationary treatment according to L(x)
Implementation of Paciorek ' s kernel where length scale is defined as a continuous function L ( x ) and computed by operations on L ( x1 ) and L ( x2 ) we globally apply ARD scaling then inside the scaled space apply an isotropic non - stationary treatment according to L ( x )
def non_stationary(x_p, x_q, params):
    assert(x_p.ndim == 2)
    if x_q is None:
        return np.ones(x_p.shape[0])
    LS_mult, LS_func = params  
    dims = x_p.shape[1]
    ls_p = LS_func(x_p)
    ls_q = LS_func(x_q)
    if dims > 1:
        assert(LS_mult.shape[0] == dims)
        assert(len(LS_mult.shape) == 1)
    assert(len(ls_p.shape) == 1)
    ls_p = ls_p[:, np.newaxis]
    ls_q = ls_q[:, np.newaxis]
    sig_mult = LS_mult**2
    sig_p = ls_p**2
    sig_q = ls_q**2
    sig_avg = 0.5*(sig_p + sig_q.T)
    ls_avg = sig_avg**0.5
    det_sig_mult = np.prod(sig_mult)
    dets_p = det_sig_mult * sig_p**dims
    dets_q = det_sig_mult * sig_q**dims
    dets_avg = det_sig_mult * sig_avg**dims
    gain = np.sqrt(np.sqrt(dets_p * dets_q.T) / dets_avg)
    return gain * np.exp(-cdist(x_p/LS_mult, x_q/LS_mult, 'sqeuclidean')
                         / ls_avg**2)
def non_stationary ( x_p , x_q , params ) : assert ( x_p . ndim == 2 ) if x_q is None : return np . ones ( x_p . shape [ 0 ] ) LS_mult , LS_func = params dims = x_p . shape [ 1 ] ls_p = LS_func ( x_p ) ls_q = LS_func ( x_q ) if dims > 1 : assert ( LS_mult . shape [ 0 ] == dims ) assert ( len ( LS_mult . shape ) == 1 ) assert ( len ( ls_p . shape ) == 1 ) ls_p = ls_p [ : , np . newaxis ] ls_q = ls_q [ : , np . newaxis ] sig_mult = LS_mult ** 2 sig_p = ls_p ** 2 sig_q = ls_q ** 2 sig_avg = 0.5 * ( sig_p + sig_q . T ) ls_avg = sig_avg ** 0.5 det_sig_mult = np . prod ( sig_mult ) dets_p = det_sig_mult * sig_p ** dims dets_q = det_sig_mult * sig_q ** dims dets_avg = det_sig_mult * sig_avg ** dims gain = np . sqrt ( np . sqrt ( dets_p * dets_q . T ) / dets_avg ) return gain * np . exp ( - cdist ( x_p / LS_mult , x_q / LS_mult , 'sqeuclidean' ) / ls_avg ** 2 )
Implementation of Paciorek's kernel where length scale is defined as
a continuous function L(x), and computed by operations on L(x1) and L(x2)
Implementation of Paciorek ' s kernel where length scale is defined as a continuous function L ( x ) and computed by operations on L ( x1 ) and L ( x2 )
""" Implementation of Paciorek's kernel where length scale is defined as
    a continuous function L(x), and computed by operations on L(x1) and L(x2)

    Note - we globally apply ARD scaling, then inside the scaled space apply an
    isotropic non-stationary treatment according to L(x)

    Arguments:
     x_p, x_q : n*d x-values
     params(list): [ (d,) np array of length-scale multipliers scaling the...,
                     function L(x) ]

    """ # Just want the magnitude to be evaluated - its always 1 :) # unpack parameters # In the diagonal [axis aligned] case, the determinants of the length # scales are simply their products # todo(AL) can probably remove det_sig_mult altogether as it should cancel # Compute non-stationary kernel
x_p
x_q
params
[ (d,) np array of length-scale multipliers scaling the...,
function L(x) ]
[ ( d ) np array of length - scale multipliers scaling the ... function L ( x ) ]
x_p, x_q 
None