Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Predict parameters of a mean_function #1022

Open
pjpessi opened this issue Jun 30, 2023 · 1 comment
Open

Predict parameters of a mean_function #1022

pjpessi opened this issue Jun 30, 2023 · 1 comment
Labels
need more info If an issue or PR needs further information by the issuer

Comments

@pjpessi
Copy link

pjpessi commented Jun 30, 2023

Hi, I am trying use a mean function with parameters that will be learnt alongside the kernel.
My kernel is
k = GPy.kern.RBF(input_dim=1,lengthscale=ls,variance=var)
I want a mean function to run
m = GPy.models.GPRegression(x,y,kernel,mean_function=mean_func)

where

mean_func = GPy.core.Mapping(1,1)
mean_func.f = lambda x: c*x 
mean_func.update_gradients = lambda a,b: None

I get NameError: name 'c' is not defined
But the thing is, I want c to be found by the regression.

I checked the parametric_mean_function that is shown here but I don't quite understand what I am doing wrong.

I would appreciate any help :)

@MartinBubel
Copy link
Contributor

Hi @pjpessi
sorry for the late response. "Lambdas are out!". Please try to use a proper function instead, e.g.

def get_mymeanfunc(c):
    def mymeanfunc(x):
        return c * x
    
    return mymeanfunc

mean_func.f = get_mymeanfunc(c)

Alternatively, it is always helpful if you provide a minimum example on how to reproduce the error.

@MartinBubel MartinBubel added the need more info If an issue or PR needs further information by the issuer label Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need more info If an issue or PR needs further information by the issuer
Projects
None yet
Development

No branches or pull requests

2 participants