Skip to content
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

MultitaskMultivariateNormal: fix tensor reshape issue #2081

Merged

Conversation

adamjstewart
Copy link
Contributor

I'm experimenting with a multitask modeling problem and encountered the following error message:

Traceback (most recent call last):
  File "train.py", line 239, in multi
    loss = -criterion(predict_y, train_y)
  File "~/lib/python3.9/site-packages/gpytorch/module.py", line 30, in __call__
    outputs = self.forward(*inputs, **kwargs)
  File "~/lib/python3.9/site-packages/gpytorch/mlls/exact_marginal_log_likelihood.py", line 62, in forward
    res = output.log_prob(target)
  File "~/lib/python3.9/site-packages/gpytorch/distributions/multitask_multivariate_normal.py", line 211, in log_prob
    return super().log_prob(value.view(*value.shape[:-2], -1))
RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

I'm not sure exactly what is causing this issue, but replacing view with reshape solved the issue for me.

Unfortunately I can't share the code or data used to reproduce this issue since it's in-progress research, but I can try to find a minimal reproducible example if you need one.

@gpleiss
Copy link
Member

gpleiss commented Jul 27, 2022

Seems super reasonable - much easier than checking whether the tensor is contiguous. Thanks @adamjstewart !

@gpleiss gpleiss merged commit 0c359c5 into cornellius-gp:master Jul 27, 2022
@adamjstewart adamjstewart deleted the fixes/multitask-multivariate-normal branch July 27, 2022 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants