{"action":"created","issue":{"url":"https://api.github.com/repos/cornellius-gp/gpytorch/issues/274","repository_url":"https://api.github.com/repos/cornellius-gp/gpytorch","labels_url":"https://api.github.com/repos/cornellius-gp/gpytorch/issues/274/labels{/name}","comments_url":"https://api.github.com/repos/cornellius-gp/gpytorch/issues/274/comments","events_url":"https://api.github.com/repos/cornellius-gp/gpytorch/issues/274/events","html_url":"https://github.com/cornellius-gp/gpytorch/issues/274","id":361114945,"node_id":"MDU6SXNzdWUzNjExMTQ5NDU=","number":274,"title":"Fowarding through RBFKernel in batch-mode broken","user":{"login":"samuelstanton","id":22999782,"node_id":"MDQ6VXNlcjIyOTk5Nzgy","avatar_url":"https://avatars3.githubusercontent.com/u/22999782?v=4","gravatar_id":"","url":"https://api.github.com/users/samuelstanton","html_url":"https://github.com/samuelstanton","followers_url":"https://api.github.com/users/samuelstanton/followers","following_url":"https://api.github.com/users/samuelstanton/following{/other_user}","gists_url":"https://api.github.com/users/samuelstanton/gists{/gist_id}","starred_url":"https://api.github.com/users/samuelstanton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samuelstanton/subscriptions","organizations_url":"https://api.github.com/users/samuelstanton/orgs","repos_url":"https://api.github.com/users/samuelstanton/repos","events_url":"https://api.github.com/users/samuelstanton/events{/privacy}","received_events_url":"https://api.github.com/users/samuelstanton/received_events","type":"User","site_admin":false},"labels":[{"id":623304451,"node_id":"MDU6TGFiZWw2MjMzMDQ0NTE=","url":"https://api.github.com/repos/cornellius-gp/gpytorch/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-09-18T02:47:04Z","updated_at":"2018-09-18T18:50:15Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"The recent changes to master have basically completely broken batch mode. This example is for the forward method in `kernels.RBFKernel`. As an example, consider the following code snippet\r\n```\r\nimport torch\r\nimport gpytorch\r\n\r\nclass BatchGP(gpytorch.models.ExactGP):\r\n    def __init__(self, train_inputs, train_targets, likelihood):\r\n        super(BatchGP, self).__init__(train_inputs, train_targets, likelihood)\r\n        self.mean_module = gpytorch.means.ConstantMean(batch_size=2)\r\n        self.covar_module = gpytorch.kernels.RBFKernel(ard_num_dims=3, batch_size=2)\r\n        self.register_parameter('log_outputscale', torch.nn.Parameter(torch.zeros(2, 1, 1)))\r\n        \r\n    def forward(self, inputs):\r\n        inputs = inputs.unsqueeze(0)\r\n        inputs = inputs.expand(2, -1, -1)\r\n        mean = self.mean_module(inputs)\r\n        prescale_covar = self.covar_module(inputs).evaluate()\r\n        covar = self.log_outputscale.exp() * prescale_covar\r\n\r\n        return self.likelihood(gpytorch.random_variables.GaussianRandomVariable(mean, covar))\r\n\r\ntrain_x = torch.rand(5, 3)\r\ntrain_y = torch.rand(5, 2)\r\nlikelihood = gpytorch.likelihoods.GaussianLikelihood()\r\n\r\nbatch_gp = BatchGP(train_x, train_y, likelihood)\r\n\r\nbatch_gp(train_x)\r\n```\r\nOut:\r\n```\r\nRuntimeError                              Traceback (most recent call last)\r\n<ipython-input-11-bbf86dd62a62> in <module>()\r\n     24 batch_gp = BatchGP(train_x, train_y, likelihood)\r\n     25 \r\n---> 26 batch_gp(train_x)\r\n\r\n~/Code/gpytorch/gpytorch/models/exact_gp.py in __call__(self, *args, **kwargs)\r\n     79                 if not all(torch.equal(train_input, input) for train_input, input in zip(train_inputs, inputs)):\r\n     80                     raise RuntimeError(\"You must train on the training inputs!\")\r\n---> 81             return super(ExactGP, self).__call__(*inputs, **kwargs)\r\n     82 \r\n     83         # Posterior mode\r\n\r\n~/Code/gpytorch/gpytorch/module.py in __call__(self, *inputs, **kwargs)\r\n    178 \r\n    179     def __call__(self, *inputs, **kwargs):\r\n--> 180         outputs = self.forward(*inputs, **kwargs)\r\n    181         if torch.is_tensor(outputs) or isinstance(outputs, RandomVariable) or isinstance(outputs, LazyTensor):\r\n    182             return outputs\r\n\r\n<ipython-input-11-bbf86dd62a62> in forward(self, inputs)\r\n     13         inputs = inputs.expand(2, -1, -1)\r\n     14         mean = self.mean_module(inputs)\r\n---> 15         prescale_covar = self.covar_module(inputs).evaluate()\r\n     16         covar = self.log_outputscale.exp() * prescale_covar\r\n     17 \r\n\r\n~/Code/gpytorch/gpytorch/lazy/lazy_evaluated_kernel_tensor.py in evaluate(self)\r\n    123 \r\n    124     def evaluate(self):\r\n--> 125         return self.evaluate_kernel().evaluate()\r\n    126 \r\n    127     def exact_predictive_mean(self, full_mean, train_labels, n_train, likelihood, precomputed_cache=None):\r\n\r\n~/Code/gpytorch/gpytorch/lazy/lazy_evaluated_kernel_tensor.py in evaluate_kernel(self)\r\n    104                 x2 = self.x2\r\n    105 \r\n--> 106             self._cached_kernel_eval = super(Kernel, self.kernel).__call__(x1, x2, **self.params)\r\n    107             if self.squeeze_row:\r\n    108                 self._cached_kernel_eval.squeeze_(-2)\r\n\r\n~/Code/gpytorch/gpytorch/module.py in __call__(self, *inputs, **kwargs)\r\n    178 \r\n    179     def __call__(self, *inputs, **kwargs):\r\n--> 180         outputs = self.forward(*inputs, **kwargs)\r\n    181         if torch.is_tensor(outputs) or isinstance(outputs, RandomVariable) or isinstance(outputs, LazyTensor):\r\n    182             return outputs\r\n\r\n~/Code/gpytorch/gpytorch/kernels/rbf_kernel.py in forward(self, x1, x2)\r\n     94     def forward(self, x1, x2):\r\n     95         x1_, x2_ = self._create_input_grid(x1, x2)\r\n---> 96         x1_ = x1_.div(self.lengthscale)\r\n     97         x2_ = x2_.div(self.lengthscale)\r\n     98 \r\n\r\nRuntimeError: The size of tensor a (5) must match the size of tensor b (2) at non-singleton dimension 1\r\n```\r\n\r\nIf you go in and look at the dimension of the tensors, `x1_.size()` is `[B x N x 1 x D]` and `self.lengthscale.size()` is `[B x 1 x D]`"},"comment":{"url":"https://api.github.com/repos/cornellius-gp/gpytorch/issues/comments/422505980","html_url":"https://github.com/cornellius-gp/gpytorch/issues/274#issuecomment-422505980","issue_url":"https://api.github.com/repos/cornellius-gp/gpytorch/issues/274","id":422505980,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMjUwNTk4MA==","user":{"login":"samuelstanton","id":22999782,"node_id":"MDQ6VXNlcjIyOTk5Nzgy","avatar_url":"https://avatars3.githubusercontent.com/u/22999782?v=4","gravatar_id":"","url":"https://api.github.com/users/samuelstanton","html_url":"https://github.com/samuelstanton","followers_url":"https://api.github.com/users/samuelstanton/followers","following_url":"https://api.github.com/users/samuelstanton/following{/other_user}","gists_url":"https://api.github.com/users/samuelstanton/gists{/gist_id}","starred_url":"https://api.github.com/users/samuelstanton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samuelstanton/subscriptions","organizations_url":"https://api.github.com/users/samuelstanton/orgs","repos_url":"https://api.github.com/users/samuelstanton/repos","events_url":"https://api.github.com/users/samuelstanton/events{/privacy}","received_events_url":"https://api.github.com/users/samuelstanton/received_events","type":"User","site_admin":false},"created_at":"2018-09-18T18:50:15Z","updated_at":"2018-09-18T18:50:15Z","author_association":"CONTRIBUTOR","body":"@gpleiss There was indeed a mistake in that example. I've update the issue with an example of the issue with forwarding through kernels in batch mode."}}
{"actor":{"display_login":"samuelstanton"}}