SheffieldML / SheffieldML/GPy

BayesianGPLVMMiniBatch and infer_newX

Open
#751 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.2k
Forks
570
PR merge metrics
No merged PRs in 30d

Description

Hello,

When I try to use infer_newX in my data I get this error:

------------------------------------------
ValueErrorTraceback (most recent call last)
<ipython-input-12-999e9683e141> in <module>
     38     for i in range(Y_test.shape[0]):
     39         Y_new = Y_test[i][np.newaxis,:]
---> 40         data_embedded, mi = m.infer_newX(Y_new, optimize=True)
     41         fitted_data = m.predict(data_embedded)
     42         Y_predicted = fitted_data[0] * Y_std + Y_mean

~/anaconda3/envs/gpyenv/lib/python3.6/site-packages/GPy/core/gp.py in infer_newX(self, Y_new, optimize)
    676         """
    677         from ..inference.latent_function_inference.inferenceX import infer_newX
--> 678         return infer_newX(self, Y_new, optimize=optimize)
    679 
    680     def log_predictive_density(self, x_test, y_test, Y_metadata=None):

~/anaconda3/envs/gpyenv/lib/python3.6/site-packages/GPy/inference/latent_function_inference/inferenceX.py in infer_newX(model, Y_new, optimize, init)
     20     :rtype: (GPy.core.parameterization.variational.VariationalPosterior, GPy.core.Model)
     21     """
---> 22     infr_m = InferenceX(model, Y_new, init=init)
     23 
     24     if optimize:

~/anaconda3/envs/gpyenv/lib/python3.6/site-packages/paramz/parameterized.py in __call__(self, *args, **kw)
     51         #import ipdb;ipdb.set_trace()
     52         initialize = kw.pop('initialize', True)
---> 53         self = super(ParametersChangedMeta, self).__call__(*args, **kw)
     54         #logger.debug("finished init")
     55         self._in_init_ = False

~/anaconda3/envs/gpyenv/lib/python3.6/site-packages/GPy/inference/latent_function_inference/inferenceX.py in __init__(self, model, Y, name, init)
     81         self.Y = Y
     82         self.X = self._init_X(model, Y, init=init)
---> 83         self.compute_dL()
     84 
     85         self.link_parameter(self.X)

~/anaconda3/envs/gpyenv/lib/python3.6/site-packages/GPy/inference/latent_function_inference/inferenceX.py in compute_dL(self)
    127                 self.dL_dpsi2 = beta/2.*(self.posterior.woodbury_inv[:,:,self.valid_dim] - tdot(wv)[:, :, None]).sum(-1)
    128             else:
--> 129                 self.dL_dpsi2 = beta/2.*(output_dim*self.posterior.woodbury_inv - tdot(wv))
    130             self.dL_dpsi1 = beta*np.dot(self.Y[:,self.valid_dim], wv.T)
    131             self.dL_dpsi0 = - beta/2.* np.ones(self.Y.shape[0])

ValueError: operands could not be broadcast together with shapes (31,31,817) (31,31) 

My training set has 817 columns and my trained model:

m = GPy.models.bayesian_gplvm_minibatch.BayesianGPLVMMiniBatch(training_input, 30, 
                                                                                 num_inducing=31,
                                                                                 missing_data=True, 
                                                                                 init = "PCA",
                                                                                 stochastic = False,
                                                                                 initialize = True)

My new data is a (1, 817) numpy array.

Regards,
Lerko

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with GPy/inference/latent_function_inference/inferenceX.py, especially compute_dL at the reported broadcasting failure, and trace the call from GPy/core/gp.py infer_newX. Reproduce it with BayesianGPLVMMiniBatch, 31 inducing points, 817 features, and a (1, 817) Y_new array. Done means infer_newX handles this input without the shape error and has a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.