def omgp_model_bound(omgp):
''' Calculate the part of the omgp bound which does not depend
on the response variable.
'''
GP_bound = 0.0
LBs = []
# Precalculate the bound minus data fit,
# and LB matrices used for data fit term.
for i, kern in enumerate(omgp.kern):
K = kern.K(omgp.X)
B_inv = np.diag(1. / ((omgp.phi[:, i] + 1e-6) / omgp.variance))
Bi, LB, LBi, Blogdet = pdinv(K + B_inv)
LBs.append(LB)
# Penalty
GP_bound -= 0.5 * Blogdet
# Constant
GP_bound -= 0.5 * omgp.D * np.einsum('j,j->', omgp.phi[:, i], np.log(2 * np.pi * omgp.variance))
model_bound = GP_bound + omgp.mixing_prop_bound() + omgp.H
return model_bound, LBs
评论列表
文章目录