SheffieldML / GPy

Gaussian processes framework in python
BSD 3-Clause "New" or "Revised" License
2.01k stars 557 forks source link

mean function output_dim don't match #570

Closed smcveigh-phunware closed 6 years ago

smcveigh-phunware commented 6 years ago

I have a linear mean function as follows:

from numpy import pi, log10

def free_space_path_loss(X):
    """
    :param X: 2-column array of [theta, radius]
    :return: free space path loss @ radius
    """
    tx = -40
    loss = 20*log10(X[:, 1]) + 20*log10(2402E6) + 20*log10(4*pi/299792458)
    return tx - loss

mean = GPy.mappings.Linear(input_dim=2, output_dim=1, name="free_space")
mean.f = free_space_path_loss

And I build a regression model:

m= GPy.models.GPRegression(
    data[['theta', 'radius']],
    data['rss'].values.reshape([-1, 1]),
    kernel=kern,   # input_dim = 2
    mean_function=mean
)

It complains that the output dimensions don't match: 2 -> len(data) rather than 2 -> 1. Am I missing something?

mzwiessele commented 6 years ago

It looks like your free_space_path_loss function does not return a column array (X[:,1]), have you tried using a column array (X[:, [1]]) as output?