Using the demo given in the demo_classification file, I am trying to do a binary classification where each of my class contains 10 samples of 73 dimensions. Following is the code where I try to 'minimize' my hyper parameters:

tempmean = zeros(1,73);
meanfunc = @meanConst; hyp.mean = tempmean;
covfunc = @covSEiso;   hyp.cov = log([1 1]);
likfunc = @likGauss; sn = 0.1; hyp.lik = log(0.1);
hyp = minimize(hyp, @gp, -100, @infExact, hyp.mean, covfunc, likfunc, x, y);

where x = [ x1 x2] (size: 73x20) and size(x1)=size(x2)=73x10. size(y) = [1x20].

taking inference function as @infEP also produces error, which is what I first intended to use.

The error I get is:

Cell contents reference from a non-cell array object.

Error in gp (line 89)
if eval(feval(mean{:})) ~= numel(hyp.mean)

Error in minimize (line 75)
[f0 df0] = feval(f, X, varargin{:});          % get function value and   gradient

Error in binary_classification_trial (line 96)
hyp = minimize(hyp, @gp, -100, @infExact, hyp.mean, covfunc, likfunc, x, y);

I would be really really grateful if anybody could help me out with this please.

On rectification:

meanfunc = @meanConst; hyp.mean = 0;
covfunc = @covSEiso;   hyp.cov = log([1 1]); 
likfunc = @likGauss; sn = 0.1; hyp.lik = log(0.1);
hyp = minimize(hyp, gp, -10, @infEP, meanfunc, covfunc, likfunc, x, y);

I get the following warning/error:

Warning: Inference method failed [Error using  -
Matrix dimensions must agree.] .. attempting to continue 
> In gp (line 128)
  In minimize (line 75)
  In binary_classification_trial (line 84) 

Function evaluation      0;  Value  NaN

Could please tell me what is wrong here?


The number of hyperparameters for your mean function is one problem. You chose your mean function to be meanConst. If you look at the code for meanConst in gpml toolbox you see that it has only one hyperparameter (instead of 73):

Constant mean function. The mean function is parameterized as: m(x) = c The hyperparameter is: hyp = [ c ]

Set your tempmean to be 0 instead of zero(1, 73).

I did not run your code to look for other errors but this one causes:

eval(feval(mean{:})) ~= numel(hyp.mean)

| cite | improve this answer | |
  • $\begingroup$ Thank you much, I rectified that. However my inference still fails and I get a hoard of warning/error msgs (as edited in the question above). Could you please tell what might be causing that? $\endgroup$ – Yeshi Sep 23 '15 at 11:52
  • $\begingroup$ You have to transpose both x and y. Every row of x is considered to be a sample. You are assuming every column of x is a sample. $\endgroup$ – Seeda Sep 23 '15 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.