gpytorch icon indicating copy to clipboard operation
gpytorch copied to clipboard

[Bug] Spectral mixture kernel implementation

Open pipme opened this issue 4 years ago • 4 comments

🐛 Bug

The forward() function's implementation in gpytorch/gpytorch/kernels/spectral_mixture_kernel.py seems to be wrong. I am also wondering which formula you are using. @gpleiss

  1. The formula (12) in this paper is uncorrected. The correction can be found in https://www.cs.cmu.edu/~andrewgw/typo.pdf. Current implementation seems to follow this uncorrected formula.
  2. In current implementation, the product and summation are in wrong order. It should compute product first and then perform summation over mixture components.

pipme avatar Nov 09 '21 14:11 pipme

Hey, @pipme and @gpleiss. Would you like to fix this with a PR or shall I give it an attempt?

patel-zeel avatar Nov 15 '21 14:11 patel-zeel

@patel-zeel I have a fixed version and may be able to make a PR later this week after some testing with batches etc.

pipme avatar Nov 15 '21 14:11 pipme

Sounds great @pipme. I was wondering if you could help me with a problem related to this kernel (forecasting Mauna loa co2). I have added the details in this discussion.

patel-zeel avatar Nov 16 '21 09:11 patel-zeel

@pipme sorry for the slow reply! We'd definitely welcome a PR, but it would have to be backwards compatible (otherwise it would be a breaking change). I think the thing to do is:

  • Create a boolean flag correct_multidimensional_mixture in the SMKernel constructor (default: False). Use the correct computations if True, and use the current code otherwise.
  • Throw a deprecation warning if correct_multidimensional_mixture is False.
  • Update the SM unit tests to test both behaviors
  • Update the SM docs to describe both behaviors

gpleiss avatar Nov 16 '21 14:11 gpleiss