2014-08-15 18:22:09 +01:00
|
|
|
# Copyright (c) 2014, James Hensman, Alan Saul
|
2015-09-07 17:26:27 +01:00
|
|
|
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
2014-08-15 18:22:09 +01:00
|
|
|
|
|
|
|
|
import numpy as np
|
2015-08-18 11:39:27 +01:00
|
|
|
from ..core import GP
|
2014-08-15 18:22:09 +01:00
|
|
|
from ..core.parameterization import ObsAr
|
|
|
|
|
from .. import kern
|
|
|
|
|
from ..core.parameterization.param import Param
|
2015-08-18 11:39:27 +01:00
|
|
|
from ..inference.latent_function_inference import VarGauss
|
2014-08-15 18:22:09 +01:00
|
|
|
|
|
|
|
|
log_2_pi = np.log(2*np.pi)
|
|
|
|
|
|
|
|
|
|
|
2015-08-18 11:39:27 +01:00
|
|
|
class GPVariationalGaussianApproximation(GP):
|
2014-08-15 18:22:09 +01:00
|
|
|
"""
|
2015-07-16 15:36:17 +01:00
|
|
|
The Variational Gaussian Approximation revisited
|
2014-08-15 18:22:09 +01:00
|
|
|
|
|
|
|
|
@article{Opper:2009,
|
|
|
|
|
title = {The Variational Gaussian Approximation Revisited},
|
|
|
|
|
author = {Opper, Manfred and Archambeau, C{\'e}dric},
|
|
|
|
|
journal = {Neural Comput.},
|
|
|
|
|
year = {2009},
|
|
|
|
|
pages = {786--792},
|
|
|
|
|
}
|
|
|
|
|
"""
|
2015-08-18 11:39:27 +01:00
|
|
|
def __init__(self, X, Y, kernel, likelihood, Y_metadata=None):
|
2015-07-16 15:36:17 +01:00
|
|
|
|
2015-08-18 11:39:27 +01:00
|
|
|
num_data = Y.shape[0]
|
|
|
|
|
self.alpha = Param('alpha', np.zeros((num_data,1))) # only one latent fn for now.
|
|
|
|
|
self.beta = Param('beta', np.ones(num_data))
|
|
|
|
|
|
|
|
|
|
inf = VarGauss(self.alpha, self.beta)
|
|
|
|
|
super(GPVariationalGaussianApproximation, self).__init__(X, Y, kernel, likelihood, name='VarGP', inference_method=inf)
|
2014-08-15 18:22:09 +01:00
|
|
|
|
2014-09-08 08:57:28 +01:00
|
|
|
self.link_parameter(self.alpha)
|
|
|
|
|
self.link_parameter(self.beta)
|