gpflow

Use of priors on hyper-parameters with SVGP model


I wanted to use priors on hyper-parameters as in (https://gpflow.readthedocs.io/en/develop/notebooks/advanced/mcmc.html) but with an SVGP model.

Following the steps of example 1, I got an error when I run de run_chain_fn :

TypeError: maximum_log_likelihood_objective() missing 1 required positional argument: 'data'

Contrary to GPR or SGPMC, the data are not an attribut of the model, they are included as external parameter.

To avoid that problem I modified slightly SVGP class to include data as parameter (I don't care with mini-batching for now)

class SVGP_with_data(gpflow.models.SVGP):
"""This model is a tiny variation of classical SVGP. It just includes the data as an optionnal 
    parameter of the model, since they are necessary of MCMC sampling"""

def __init__(self,data,**kwargs):
    super().__init__(**kwargs)
    self.data = data
    
def maximum_log_likelihood_objective(self,_=None):
    return self.elbo(self.data)     #here we don't care about mini-batching

It seems to work well.

I couldn't find code example of SVGP with priors on hyper-parameters. Is their a more standard way to deel with this ?

Thanks !


Solution

  • SVGP is a GPflow model for a variational approximation. Using MCMC on the q(u) distribution parameterised by q_mu and q_sqrt doesn't make sense (if you want to do MCMC on q(u) in a sparse approximation, use SGPMC).

    You can still put (hyper)priors on the hyperparameters in the SVGP model; gradient-based optimisation will then lead to the maximum a-posteriori (MAP) point estimate (as opposed to pure maximum likelihood).