{"action":"opened","issue":{"url":"https://api.github.com/repos/cornellius-gp/gpytorch/issues/382","repository_url":"https://api.github.com/repos/cornellius-gp/gpytorch","labels_url":"https://api.github.com/repos/cornellius-gp/gpytorch/issues/382/labels{/name}","comments_url":"https://api.github.com/repos/cornellius-gp/gpytorch/issues/382/comments","events_url":"https://api.github.com/repos/cornellius-gp/gpytorch/issues/382/events","html_url":"https://github.com/cornellius-gp/gpytorch/issues/382","id":381857745,"node_id":"MDU6SXNzdWUzODE4NTc3NDU=","number":382,"title":"RuntimeError: TensorIterator expected type torch.DoubleTensor but got torch.FloatTensor","user":{"login":"dust0x","id":6918743,"node_id":"MDQ6VXNlcjY5MTg3NDM=","avatar_url":"https://avatars0.githubusercontent.com/u/6918743?v=4","gravatar_id":"","url":"https://api.github.com/users/dust0x","html_url":"https://github.com/dust0x","followers_url":"https://api.github.com/users/dust0x/followers","following_url":"https://api.github.com/users/dust0x/following{/other_user}","gists_url":"https://api.github.com/users/dust0x/gists{/gist_id}","starred_url":"https://api.github.com/users/dust0x/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dust0x/subscriptions","organizations_url":"https://api.github.com/users/dust0x/orgs","repos_url":"https://api.github.com/users/dust0x/repos","events_url":"https://api.github.com/users/dust0x/events{/privacy}","received_events_url":"https://api.github.com/users/dust0x/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-17T12:13:58Z","updated_at":"2018-11-17T12:13:58Z","closed_at":null,"author_association":"NONE","body":"For the inputs, I load a pandas dataframe and cast the required columns to a torch tensor.\r\n\r\nAlso, I'm using the following arbitrary kernel:\r\n\r\n```python\r\ngpytorch.kernels.ScaleKernel(gpytorch.kernels.RBFKernel() + gpytorch.kernels.WhiteNoiseKernel(variances=_variances))\r\n```\r\nOn initialising the model object as `model = GPModel(Y, _y, likelihood)` the same `RuntimeError` as in the title is thrown at [this line](https://github.com/cornellius-gp/gpytorch/blob/master/gpytorch/distributions/multivariate_normal.py#L109).\r\n\r\nThe most obvious solution to this, it seemed, was `model = GPModel(Y, _y, likelihood).model()` and indeed that made everything work. Well, everything except `observed_pred.confidence_region()` which throws the same error. The trace is as below:\r\n\r\n<details><summary> (click to uncollapse) </summary>\r\n\r\n<p>\r\n\r\n```\r\n---------------------------------------------------------------------------\r\nRuntimeError                              Traceback (most recent call last)\r\n<ipython-input-47-9d427a67dd6f> in <module>\r\n----> 1 observed_pred.confidence_region()\r\n\r\n~/.pyenv/versions/3.6.4/lib/python3.6/site-packages/gpytorch/distributions/multivariate_normal.py in confidence_region(self)\r\n     74 \r\n     75         \"\"\"\r\n---> 76         std2 = self.stddev.mul_(2)\r\n     77         mean = self.mean\r\n     78         return mean.sub(std2), mean.add(std2)\r\n\r\n~/.pyenv/versions/3.6.4/lib/python3.6/site-packages/torch/distributions/distribution.py in stddev(self)\r\n    108         Returns the standard deviation of the distribution.\r\n    109         \"\"\"\r\n--> 110         return self.variance.sqrt()\r\n    111 \r\n    112     def sample(self, sample_shape=torch.Size()):\r\n\r\n~/.pyenv/versions/3.6.4/lib/python3.6/site-packages/gpytorch/distributions/multivariate_normal.py in variance(self)\r\n    169                 return self.lazy_covariance_matrix.diag().unsqueeze(-1).expand(self._batch_shape + self._event_shape)\r\n    170             else:\r\n--> 171                 return self.lazy_covariance_matrix.diag().expand(self._batch_shape + self._event_shape)\r\n    172         else:\r\n    173             return super(_MultivariateNormalBase, self).variance\r\n\r\n~/.pyenv/versions/3.6.4/lib/python3.6/site-packages/gpytorch/lazy/sum_lazy_tensor.py in diag(self)\r\n     87 \r\n     88     def diag(self):\r\n---> 89         diags = [lazy_tensor.diag().contiguous() for lazy_tensor in self.lazy_tensors]\r\n     90         size = diags[0].size()\r\n     91         res = sum(diag.view(-1) for diag in diags)\r\n\r\n~/.pyenv/versions/3.6.4/lib/python3.6/site-packages/gpytorch/lazy/sum_lazy_tensor.py in <listcomp>(.0)\r\n     87 \r\n     88     def diag(self):\r\n---> 89         diags = [lazy_tensor.diag().contiguous() for lazy_tensor in self.lazy_tensors]\r\n     90         size = diags[0].size()\r\n     91         res = sum(diag.view(-1) for diag in diags)\r\n\r\n~/.pyenv/versions/3.6.4/lib/python3.6/site-packages/gpytorch/lazy/sum_lazy_tensor.py in diag(self)\r\n     87 \r\n     88     def diag(self):\r\n---> 89         diags = [lazy_tensor.diag().contiguous() for lazy_tensor in self.lazy_tensors]\r\n     90         size = diags[0].size()\r\n     91         res = sum(diag.view(-1) for diag in diags)\r\n\r\n~/.pyenv/versions/3.6.4/lib/python3.6/site-packages/gpytorch/lazy/sum_lazy_tensor.py in <listcomp>(.0)\r\n     87 \r\n     88     def diag(self):\r\n---> 89         diags = [lazy_tensor.diag().contiguous() for lazy_tensor in self.lazy_tensors]\r\n     90         size = diags[0].size()\r\n     91         res = sum(diag.view(-1) for diag in diags)\r\n\r\n~/.pyenv/versions/3.6.4/lib/python3.6/site-packages/gpytorch/lazy/lazy_evaluated_kernel_tensor.py in diag(self)\r\n     86                 x2 = x2.unsqueeze(1)\r\n     87 \r\n---> 88             res = super(Kernel, self.kernel).__call__(x1, x2, diag=True, batch_dims=self.batch_dims, **self.params)\r\n     89 \r\n     90             # Did this Kernel eat the diag option?\r\n\r\n~/.pyenv/versions/3.6.4/lib/python3.6/site-packages/gpytorch/module.py in __call__(self, *inputs, **kwargs)\r\n     18 \r\n     19     def __call__(self, *inputs, **kwargs):\r\n---> 20         outputs = self.forward(*inputs, **kwargs)\r\n     21 \r\n     22         if isinstance(outputs, tuple):\r\n\r\n~/.pyenv/versions/3.6.4/lib/python3.6/site-packages/gpytorch/kernels/scale_kernel.py in forward(self, x1, x2, batch_dims, **params)\r\n     67             outputscales = outputscales.unsqueeze(1).repeat(1, x1.size(-1)).view(-1)\r\n     68 \r\n---> 69         orig_output = self.base_kernel(x1, x2, batch_dims=batch_dims, **params)\r\n     70         if torch.is_tensor(orig_output):\r\n     71             outputscales = outputscales.view(-1, *([1] * (orig_output.dim() - 1)))\r\n\r\n~/.pyenv/versions/3.6.4/lib/python3.6/site-packages/gpytorch/kernels/kernel.py in __call__(self, x1, x2, diag, batch_dims, **params)\r\n    248 \r\n    249         if diag:\r\n--> 250             res = super(Kernel, self).__call__(x1_, x2_, diag=True, batch_dims=batch_dims, **params)\r\n    251 \r\n    252             # Did this Kernel eat the diag option?\r\n\r\n~/.pyenv/versions/3.6.4/lib/python3.6/site-packages/gpytorch/module.py in __call__(self, *inputs, **kwargs)\r\n     18 \r\n     19     def __call__(self, *inputs, **kwargs):\r\n---> 20         outputs = self.forward(*inputs, **kwargs)\r\n     21 \r\n     22         if isinstance(outputs, tuple):\r\n\r\n~/.pyenv/versions/3.6.4/lib/python3.6/site-packages/gpytorch/kernels/kernel.py in forward(self, x1, x2, **params)\r\n    339             if isinstance(next_term, LazyEvaluatedKernelTensor):\r\n    340                 next_term = next_term.evaluate_kernel()\r\n--> 341             res = res + next_term\r\n    342         return res\r\n    343 \r\n\r\nRuntimeError: TensorIterator expected type torch.DoubleTensor but got torch.FloatTensor\r\n```\r\n</p>\r\n</details>\r\n\r\n\r\nMy code is pretty much the same as the simple regression example except the inputs and the kernel used. If required, I could upload an example dataframe for reproducing this error.\r\n\r\nOne thing to note is that this (ie., the second error, the first error happens for any kernel) happens specifically with the `WhiteNoiseKernel`. Is it possible I'm using it incorrectly?"}}
{"actor":{"display_login":"dust0x"}}