Skip to content

BUG: Combination covariance errors with WhiteNoise #6673

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

Closed
dehorsley opened this issue Apr 14, 2023 · 2 comments
Closed

BUG: Combination covariance errors with WhiteNoise #6673

dehorsley opened this issue Apr 14, 2023 · 2 comments
Labels
bug GP Gaussian Process

Comments

@dehorsley
Copy link
Contributor

dehorsley commented Apr 14, 2023

Describe the issue:

Post v5.2.0, gp.cov.Combination covariance has extra checks (at cov.py:189) that fail with a WhiteNoise covariance.

Currently, the check for input_dim equality fails there is also a lurking problem with calculating active_dims.

Reproduceable code example:

import pm
pm.gp.cov.Exponential(2, ls=1) + pm.gp.cov.WhiteNoise(sigma=1)

Error message:

AttributeError                            Traceback (most recent call last)

<ipython-input-1-7257c4d70473> in <cell line: 3>()
      1 import pymc as pm
      2 print(pm.__version__)
----> 3 pm.gp.cov.Exponential(2, ls=1) + pm.gp.cov.WhiteNoise(sigma=1)

2 frames

/usr/local/lib/python3.9/dist-packages/pymc/gp/cov.py in __add__(self, other)
     83         if isinstance(other, numbers.Real):
     84             other = Constant(c=other)
---> 85         return Add([self, other])
     86 
     87     def __mul__(self, other):

/usr/local/lib/python3.9/dist-packages/pymc/gp/cov.py in __init__(self, factor_list)
    187 
    188         # Check if all input_dim are the same in factor_list
--> 189         input_dims = {factor.input_dim for factor in factor_list if isinstance(factor, Covariance)}
    190 
    191         if len(input_dims) != 1:

/usr/local/lib/python3.9/dist-packages/pymc/gp/cov.py in <setcomp>(.0)
    187 
    188         # Check if all input_dim are the same in factor_list
--> 189         input_dims = {factor.input_dim for factor in factor_list if isinstance(factor, Covariance)}
    190 
    191         if len(input_dims) != 1:

AttributeError: 'WhiteNoise' object has no attribute 'input_dim'

PyMC version information:

pymc==5.2.0

installed via pip

OS: *

Context for the issue:

Affects any use of latent GPs with noise.

@dehorsley dehorsley added the bug label Apr 14, 2023
@dehorsley
Copy link
Contributor Author

dehorsley commented Apr 14, 2023

Likely also an issue with Constant covariance kernel

Edit: actually no, because Constant is a subclass of BaseCovariance, not Covariance. It looks like it was intended for WhiteNoise to do the same.

dehorsley added a commit to dehorsley/pymc that referenced this issue Apr 18, 2023
Since pymc-devs#6458, Covariance is now the base class for kernels/covariance
functions with input_dim and active_dims, which does not include
WhiteNoise and Constant kernels.
dehorsley added a commit to dehorsley/pymc that referenced this issue Apr 18, 2023
@ricardoV94 ricardoV94 added the GP Gaussian Process label Apr 19, 2023
ricardoV94 pushed a commit that referenced this issue Apr 26, 2023
* fix WhiteNoise subclassing from Covariance (#6673)

Since #6458, Covariance is now the base class for kernels/covariance
functions with input_dim and active_dims, which does not include
WhiteNoise and Constant kernels.

* add regression test for #6673

* fix WhiteNoise input to marginal GP
@ricardoV94
Copy link
Member

Closed via #6674

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug GP Gaussian Process
Projects
None yet
Development

No branches or pull requests

2 participants