activatedgeek / simplex-gp

Lattice kernels for scalable Gaussian processes in GPyTorch (Simplex-GPs)
https://go.sanyamkapoor.com/simplex-gp
Apache License 2.0
9 stars 2 forks source link

Kernel dimension mismatch #1

Closed activatedgeek closed 4 years ago

activatedgeek commented 4 years ago

After fixing a little condition here here is an error I get. Unclear if this really a GPyTorch bug or something in RectangularLazyBilateral. This only happens for the test data.

File "experiments/train.py", line 97, in <module>
    fire.Fire(main)
  File "/misc/vlgscratch4/WilsonGroup/sanyam/.conda/envs/bilateral-gp/lib/python3.7/site-packages/fire/core.py", line 138, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/misc/vlgscratch4/WilsonGroup/sanyam/.conda/envs/bilateral-gp/lib/python3.7/site-packages/fire/core.py", line 468, in _Fire
    target=component.__name__)
  File "/misc/vlgscratch4/WilsonGroup/sanyam/.conda/envs/bilateral-gp/lib/python3.7/site-packages/fire/core.py", line 672, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "experiments/train.py", line 86, in main
    m = model(test_x)
  File "/misc/vlgscratch4/WilsonGroup/sanyam/.conda/envs/bilateral-gp/lib/python3.7/site-packages/gpytorch/models/exact_gp.py", line 328, in __call__
    predictive_mean, predictive_covar = self.prediction_strategy.exact_prediction(full_mean, full_covar)
  File "/misc/vlgscratch4/WilsonGroup/sanyam/.conda/envs/bilateral-gp/lib/python3.7/site-packages/gpytorch/models/exact_prediction_strategies.py", line 302, in exact_prediction
    self.exact_predictive_mean(test_mean, test_train_covar),
  File "/misc/vlgscratch4/WilsonGroup/sanyam/.conda/envs/bilateral-gp/lib/python3.7/site-packages/gpytorch/models/exact_prediction_strategies.py", line 320, in exact_predictive_mean
    res = (test_train_covar @ self.mean_cache.unsqueeze(-1)).squeeze(-1)
  File "/misc/vlgscratch4/WilsonGroup/sanyam/.conda/envs/bilateral-gp/lib/python3.7/site-packages/gpytorch/lazy/lazy_tensor.py", line 1739, in __matmul__
    return self.matmul(other)
  File "/misc/vlgscratch4/WilsonGroup/sanyam/.conda/envs/bilateral-gp/lib/python3.7/site-packages/gpytorch/lazy/lazy_tensor.py", line 1097, in matmul
    return func.apply(self.representation_tree(), other, *self.representation())
  File "/misc/vlgscratch4/WilsonGroup/sanyam/.conda/envs/bilateral-gp/lib/python3.7/site-packages/gpytorch/lazy/lazy_evaluated_kernel_tensor.py", line 322, in representation_tree
    return self.evaluate_kernel().representation_tree()
  File "/misc/vlgscratch4/WilsonGroup/sanyam/.conda/envs/bilateral-gp/lib/python3.7/site-packages/gpytorch/utils/memoize.py", line 34, in g
    add_to_cache(self, cache_name, method(self, *args, **kwargs))
  File "/misc/vlgscratch4/WilsonGroup/sanyam/.conda/envs/bilateral-gp/lib/python3.7/site-packages/gpytorch/lazy/lazy_evaluated_kernel_tensor.py", line 287, in evaluate_kernel
    f"The expected shape of the kernel was {self.shape}, but got {res.shape}. "
RuntimeError: The expected shape of the kernel was torch.Size([86975, 278319]), but got torch.Size([278319, 86975]). This is likely a bug in GPyTorch.

cc @mfinzi

activatedgeek commented 4 years ago

The notebook works fine and I was able to generate all the graphs.

KeAWang commented 4 years ago

Looks like the tensor is transposed. This is most likely an error in the custom LazyTensor. I'll take a look at it tomorrow

activatedgeek commented 4 years ago

@KeAWang let me know if you had a chance to look at this. Thanks!