gpytorch/likelihoods/multitask_gaussian_likelihood.py
def forward(self, input, *params):
        """
        Adds the task noises to the diagonal of the covariance matrix of the supplied
        :obj:`gpytorch.distributions.MultivariateNormal` or :obj:`gpytorch.distributions.MultitaskMultivariateNormal`,
        in case of `rank` == 0. Otherwise, adds a rank `rank` covariance matrix to it.

        This scales the task correlations appropriately by the variances at the different points provided
        by the noise variance model (evalutated at the provided params)
        """
        mean, covar = input.mean, input.lazy_covariance_matrix
        batch_shape, n = covar.shape[:-2], covar.shape[-1] // self.num_tasks

        if len(batch_shape) > 1:
            raise NotImplementedError("Batch shapes with dim > 1 not yet supported for MulitTask Likelihoods")

        # compute the noise covariance
        if len(params) > 0:
            shape = None
        else:
            shape = mean.shape if len(mean.shape) == 1 else mean.shape[:-1]
        noise_covar = self.noise_covar(*params, shape=shape)

        if hasattr(self, "task_noise_corr_factor"):
            # if rank > 0, compute the task correlation matrix
            # TODO: This is inefficient, change repeat so it can repeat LazyTensors w/ multiple batch dimensions
            task_corr = self._eval_corr_matrix()
            exp_shape = batch_shape + torch.Size([n]) + task_corr.shape[-2:]
            if len(batch_shape) == 1:
                task_corr = task_corr.unsqueeze(-3)
            task_corr_exp = NonLazyTensor(task_corr.expand(exp_shape))
            noise_sem = noise_covar.sqrt()
            task_covar_blocks = MatmulLazyTensor(MatmulLazyTensor(noise_sem, task_corr_exp), noise_sem)
        else:
            # otherwise tasks are uncorrelated
            task_covar_blocks = noise_covar

        if len(batch_shape) == 1:
            # TODO: Properly support general batch shapes in BlockDiagLazyTensor (no shape arithmetic)
            tcb_eval = task_covar_blocks.evaluate()
            task_covar = BlockDiagLazyTensor(
                NonLazyTensor(tcb_eval.view(-1, *tcb_eval.shape[-2:])), num_blocks=tcb_eval.shape[0]
            )
        else:
            task_covar = BlockDiagLazyTensor(task_covar_blocks)
        return input.__class__(mean, covar + task_covar)

        Adds the task noises to the diagonal of the covariance matrix of the supplied
        :obj:`gpytorch.distributions.MultivariateNormal` or :obj:`gpytorch.distributions.MultitaskMultivariateNormal`,
        in case of `rank` == 0. Otherwise, adds a rank `rank` covariance matrix to it.

        This scales the task correlations appropriately by the variances at the different points provided
        by the noise variance model (evalutated at the provided params)
        
Adds the task noises to the diagonal of the covariance matrix of the supplied
Adds the task noises to the diagonal of the covariance matrix of the supplied
def forward(self, input, *params):
        mean, covar = input.mean, input.lazy_covariance_matrix
        batch_shape, n = covar.shape[:-2], covar.shape[-1] // self.num_tasks
        if len(batch_shape) > 1:
            raise NotImplementedError("Batch shapes with dim > 1 not yet supported for MulitTask Likelihoods")
        if len(params) > 0:
            shape = None
        else:
            shape = mean.shape if len(mean.shape) == 1 else mean.shape[:-1]
        noise_covar = self.noise_covar(*params, shape=shape)
        if hasattr(self, "task_noise_corr_factor"):
            task_corr = self._eval_corr_matrix()
            exp_shape = batch_shape + torch.Size([n]) + task_corr.shape[-2:]
            if len(batch_shape) == 1:
                task_corr = task_corr.unsqueeze(-3)
            task_corr_exp = NonLazyTensor(task_corr.expand(exp_shape))
            noise_sem = noise_covar.sqrt()
            task_covar_blocks = MatmulLazyTensor(MatmulLazyTensor(noise_sem, task_corr_exp), noise_sem)
        else:
            task_covar_blocks = noise_covar
        if len(batch_shape) == 1:
            tcb_eval = task_covar_blocks.evaluate()
            task_covar = BlockDiagLazyTensor(
                NonLazyTensor(tcb_eval.view(-1, *tcb_eval.shape[-2:])), num_blocks=tcb_eval.shape[0]
            )
        else:
            task_covar = BlockDiagLazyTensor(task_covar_blocks)
        return input.__class__(mean, covar + task_covar)
def forward ( self , input , * params ) : mean , covar = input . mean , input . lazy_covariance_matrix batch_shape , n = covar . shape [ : - 2 ] , covar . shape [ - 1 ] // self . num_tasks if len ( batch_shape ) > 1 : raise NotImplementedError ( "Batch shapes with dim > 1 not yet supported for MulitTask Likelihoods" ) if len ( params ) > 0 : shape = None else : shape = mean . shape if len ( mean . shape ) == 1 else mean . shape [ : - 1 ] noise_covar = self . noise_covar ( * params , shape = shape ) if hasattr ( self , "task_noise_corr_factor" ) : task_corr = self . _eval_corr_matrix ( ) exp_shape = batch_shape + torch . Size ( [ n ] ) + task_corr . shape [ - 2 : ] if len ( batch_shape ) == 1 : task_corr = task_corr . unsqueeze ( - 3 ) task_corr_exp = NonLazyTensor ( task_corr . expand ( exp_shape ) ) noise_sem = noise_covar . sqrt ( ) task_covar_blocks = MatmulLazyTensor ( MatmulLazyTensor ( noise_sem , task_corr_exp ) , noise_sem ) else : task_covar_blocks = noise_covar if len ( batch_shape ) == 1 : tcb_eval = task_covar_blocks . evaluate ( ) task_covar = BlockDiagLazyTensor ( NonLazyTensor ( tcb_eval . view ( - 1 , * tcb_eval . shape [ - 2 : ] ) ) , num_blocks = tcb_eval . shape [ 0 ] ) else : task_covar = BlockDiagLazyTensor ( task_covar_blocks ) return input . __class__ ( mean , covar + task_covar )
Adds the task noises to the diagonal of the covariance matrix of the supplied
Adds the task noises to the diagonal of the covariance matrix of the supplied
"""
        Adds the task noises to the diagonal of the covariance matrix of the supplied
        :obj:`gpytorch.distributions.MultivariateNormal` or :obj:`gpytorch.distributions.MultitaskMultivariateNormal`,
        in case of `rank` == 0. Otherwise, adds a rank `rank` covariance matrix to it.

        This scales the task correlations appropriately by the variances at the different points provided
        by the noise variance model (evalutated at the provided params)
        """ # compute the noise covariance # if rank > 0, compute the task correlation matrix # TODO: This is inefficient, change repeat so it can repeat LazyTensors w/ multiple batch dimensions # otherwise tasks are uncorrelated # TODO: Properly support general batch shapes in BlockDiagLazyTensor (no shape arithmetic)
self
input
obj
`gpytorch.distributions.MultivariateNormal` or :obj:`gpytorch.distributions.MultitaskMultivariateNormal`,
in case of `rank` == 0. Otherwise, adds a rank `rank` covariance matrix to it.

This scales the task correlations appropriately by the variances at the different points provided
by the noise variance model (evalutated at the provided params)
` gpytorch . distributions . MultivariateNormal ` or : obj : ` gpytorch . distributions . MultitaskMultivariateNormal ` in case of ` rank ` == 0 . Otherwise adds a rank ` rank ` covariance matrix to it . This scales the task correlations appropriately by the variances at the different points provided by the noise variance model ( evalutated at the provided params )