SheffieldML / GPy

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

inconsistent input_dim when adding/multiplying kernels #498

Closed pgmoren closed 6 years ago

pgmoren commented 7 years ago

The definition of input_dim seems to be non-consistent. In a base kernel, input_dim seems to represent the dimensionality of the inputs and does not change when we change active_dims.

However, when we add/multiply two kernels with same input dimensionality, the variable input_dim seems to be recomputed, i.e. as the cardinality of the union set of the active_dims of the original kernels.

Should not be the input_dim of the output kernel equal to that of the inputs?

In my opinion, in the example below, "print k3.input_dim" should output 2 instead of 1.

k1 = GPy.kern.RBF(2)
k1.active_dims = [1]
print k1.input_dim

k2 = GPy.kern.RBF(2)
k2.active_dims = [1]
print k2.input_dim

k3 = k1 + k2
print k3.active_dims
print k3.input_dim
mzwiessele commented 7 years ago

No actually not. The active dimensions are the important part and in your example there is only ONE active dimension. So the input dimensionality is one.

On 12 Apr 2017, at 14:38, pgmoren notifications@github.com wrote:

The definition of input_dim seems to be non-consistent. In a base kernel, input_dim seems to represent the dimensionality of the inputs and does not change when we change active_dims.

However, when we add/multiply two kernels with same input dimensionality, the variable input_dim seems to be recomputed, i.e. as the cardinality of the union set of the active_dims of the original kernels.

Should not be the input_dim of the output kernel equal to that of the inputs?

In my opinion, in the example below, "print k3.input_dim" should output 2 instead of 1.

k1 = GPy.kern.RBF(2) k1.active_dims = [1] print k1.input_dim

k2 = GPy.kern.RBF(2) k2.active_dims = [1] print k2.input_dim

k3 = k1 + k2 print k3.active_dims print k3.input_dim — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

pgmoren commented 7 years ago

But then, Should not be print k1.input_dim and print k2.input_dim print also 1? Following the same reasoning there is only one active dimension. It seems that in k1 and k2 input_dim represents the dimensionality of the original space, but in k3 represents the number of active dimensions instead. Am I missing something? Thank you.

mzwiessele commented 7 years ago

Indeed it should! Now I am getting what you are saying. It is the difference between automatic setting of the input dimension and manual setting by the user. The inconsitency comes from the user setting the input dimension to two, but then only using one dimension of it.

On 12 Apr 2017, at 14:38, pgmoren notifications@github.com wrote:

The definition of input_dim seems to be non-consistent. In a base kernel, input_dim seems to represent the dimensionality of the inputs and does not change when we change active_dims.

However, when we add/multiply two kernels with same input dimensionality, the variable input_dim seems to be recomputed, i.e. as the cardinality of the union set of the active_dims of the original kernels.

Should not be the input_dim of the output kernel equal to that of the inputs?

In my opinion, in the example below, "print k3.input_dim" should output 2 instead of 1.

k1 = GPy.kern.RBF(2) k1.active_dims = [1] print k1.input_dim

k2 = GPy.kern.RBF(2) k2.active_dims = [1] print k2.input_dim

k3 = k1 + k2 print k3.active_dims print k3.input_dim — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

debipe20 commented 7 years ago

what is the basic difference between input dimension & active dimension?

mzwiessele commented 6 years ago

Active dimension is the dimensions which are actually being used by the kernel ( and subsequent kernels) as computed by the framework. Input dimension is the dimensionality of the input X, as specified by the user.