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.

        To accomplish this, we form a new :obj:`gpytorch.lazy.KroneckerProductLazyTensor` between :math:`I_{n}`,
        an identity matrix with size equal to the data and a (not necessarily diagonal) matrix containing the task
        noises :math:`D_{t}`.

        We also incorporate a shared `noise` parameter from the base
        :class:`gpytorch.likelihoods.GaussianLikelihood` that we extend.

        The final covariance matrix after this method is then :math:`K + D_{t} \otimes I_{n} + \sigma^{2}I_{nt}`.

        Args:
            input (:obj:`gpytorch.distributions.MultitaskMultivariateNormal`): Random variable whose covariance
                matrix is a :obj:`gpytorch.lazy.LazyTensor` we intend to augment.
        Returns:
            :obj:`gpytorch.distributions.MultitaskMultivariateNormal`: A new random variable whose covariance
            matrix is a :obj:`gpytorch.lazy.LazyTensor` with :math:`D_{t} \otimes I_{n}` and :math:`\sigma^{2}I_{nt}`
            added.
        """
        mean, covar = input.mean, input.lazy_covariance_matrix

        if self.rank == 0:
            task_noises = self._param_transform(self.raw_task_noises)
            if covar.ndimension() == 2:
                if settings.debug.on() and task_noises.size(0) > 1:
                    raise RuntimeError(
                        "With batch_size > 1, expected a batched MultitaskMultivariateNormal distribution."
                    )
                task_noises = task_noises.squeeze(0)
            task_var_lt = DiagLazyTensor(task_noises)
            device = task_noises.device
        else:
            task_noise_covar_factor = self.task_noise_covar_factor
            if covar.ndimension() == 2:
                if settings.debug.on() and task_noise_covar_factor.size(0) > 1:
                    raise RuntimeError(
                        "With batch_size > 1, expected a batched MultitaskMultivariateNormal distribution."
                    )
                task_noise_covar_factor = task_noise_covar_factor.squeeze(0)
            task_var_lt = RootLazyTensor(task_noise_covar_factor)
            device = task_noise_covar_factor.device

        if covar.ndimension() == 2:
            eye_lt = DiagLazyTensor(torch.ones(covar.size(-1) // self.num_tasks, device=device))
        else:
            eye_lt = DiagLazyTensor(torch.ones(covar.size(0), covar.size(-1) // self.num_tasks, device=device))
            # Make sure the batch sizes are going to match
            if task_var_lt.size(0) == 1:
                task_var_lt = task_var_lt.repeat(eye_lt.size(0), 1, 1)

        covar_kron_lt = KroneckerProductLazyTensor(task_var_lt, eye_lt)
        covar = covar + covar_kron_lt

        noise = self.noise
        if covar.ndimension() == 2:
            if settings.debug.on() and noise.size(0) > 1:
                raise RuntimeError("With batch_size > 1, expected a batched MultitaskMultivariateNormal distribution.")
            noise = noise.squeeze(0)

        covar = add_diag(covar, noise)
        return input.__class__(mean, 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.

        To accomplish this, we form a new :obj:`gpytorch.lazy.KroneckerProductLazyTensor` between :math:`I_{n}`,
        an identity matrix with size equal to the data and a (not necessarily diagonal) matrix containing the task
        noises :math:`D_{t}`.

        We also incorporate a shared `noise` parameter from the base
        :class:`gpytorch.likelihoods.GaussianLikelihood` that we extend.

        The final covariance matrix after this method is then :math:`K + D_{t} \otimes I_{n} + \sigma^{2}I_{nt}`.

        Args:
            input (:obj:`gpytorch.distributions.MultitaskMultivariateNormal`): Random variable whose covariance
                matrix is a :obj:`gpytorch.lazy.LazyTensor` we intend to augment.
        Returns:
            :obj:`gpytorch.distributions.MultitaskMultivariateNormal`: A new random variable whose covariance
            matrix is a :obj:`gpytorch.lazy.LazyTensor` with :math:`D_{t} \otimes I_{n}` and :math:`\sigma^{2}I_{nt}`
            added.
        
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
        if self.rank == 0:
            task_noises = self._param_transform(self.raw_task_noises)
            if covar.ndimension() == 2:
                if settings.debug.on() and task_noises.size(0) > 1:
                    raise RuntimeError(
                        "With batch_size > 1, expected a batched MultitaskMultivariateNormal distribution."
                    )
                task_noises = task_noises.squeeze(0)
            task_var_lt = DiagLazyTensor(task_noises)
            device = task_noises.device
        else:
            task_noise_covar_factor = self.task_noise_covar_factor
            if covar.ndimension() == 2:
                if settings.debug.on() and task_noise_covar_factor.size(0) > 1:
                    raise RuntimeError(
                        "With batch_size > 1, expected a batched MultitaskMultivariateNormal distribution."
                    )
                task_noise_covar_factor = task_noise_covar_factor.squeeze(0)
            task_var_lt = RootLazyTensor(task_noise_covar_factor)
            device = task_noise_covar_factor.device
        if covar.ndimension() == 2:
            eye_lt = DiagLazyTensor(torch.ones(covar.size(-1) // self.num_tasks, device=device))
        else:
            eye_lt = DiagLazyTensor(torch.ones(covar.size(0), covar.size(-1) // self.num_tasks, device=device))
            if task_var_lt.size(0) == 1:
                task_var_lt = task_var_lt.repeat(eye_lt.size(0), 1, 1)
        covar_kron_lt = KroneckerProductLazyTensor(task_var_lt, eye_lt)
        covar = covar + covar_kron_lt
        noise = self.noise
        if covar.ndimension() == 2:
            if settings.debug.on() and noise.size(0) > 1:
                raise RuntimeError("With batch_size > 1, expected a batched MultitaskMultivariateNormal distribution.")
            noise = noise.squeeze(0)
        covar = add_diag(covar, noise)
        return input.__class__(mean, covar)
def forward ( self , input , * params ) : mean , covar = input . mean , input . lazy_covariance_matrix if self . rank == 0 : task_noises = self . _param_transform ( self . raw_task_noises ) if covar . ndimension ( ) == 2 : if settings . debug . on ( ) and task_noises . size ( 0 ) > 1 : raise RuntimeError ( "With batch_size > 1, expected a batched MultitaskMultivariateNormal distribution." ) task_noises = task_noises . squeeze ( 0 ) task_var_lt = DiagLazyTensor ( task_noises ) device = task_noises . device else : task_noise_covar_factor = self . task_noise_covar_factor if covar . ndimension ( ) == 2 : if settings . debug . on ( ) and task_noise_covar_factor . size ( 0 ) > 1 : raise RuntimeError ( "With batch_size > 1, expected a batched MultitaskMultivariateNormal distribution." ) task_noise_covar_factor = task_noise_covar_factor . squeeze ( 0 ) task_var_lt = RootLazyTensor ( task_noise_covar_factor ) device = task_noise_covar_factor . device if covar . ndimension ( ) == 2 : eye_lt = DiagLazyTensor ( torch . ones ( covar . size ( - 1 ) // self . num_tasks , device = device ) ) else : eye_lt = DiagLazyTensor ( torch . ones ( covar . size ( 0 ) , covar . size ( - 1 ) // self . num_tasks , device = device ) ) if task_var_lt . size ( 0 ) == 1 : task_var_lt = task_var_lt . repeat ( eye_lt . size ( 0 ) , 1 , 1 ) covar_kron_lt = KroneckerProductLazyTensor ( task_var_lt , eye_lt ) covar = covar + covar_kron_lt noise = self . noise if covar . ndimension ( ) == 2 : if settings . debug . on ( ) and noise . size ( 0 ) > 1 : raise RuntimeError ( "With batch_size > 1, expected a batched MultitaskMultivariateNormal distribution." ) noise = noise . squeeze ( 0 ) covar = add_diag ( covar , noise ) return input . __class__ ( mean , 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.

        To accomplish this, we form a new :obj:`gpytorch.lazy.KroneckerProductLazyTensor` between :math:`I_{n}`,
        an identity matrix with size equal to the data and a (not necessarily diagonal) matrix containing the task
        noises :math:`D_{t}`.

        We also incorporate a shared `noise` parameter from the base
        :class:`gpytorch.likelihoods.GaussianLikelihood` that we extend.

        The final covariance matrix after this method is then :math:`K + D_{t} \otimes I_{n} + \sigma^{2}I_{nt}`.

        Args:
            input (:obj:`gpytorch.distributions.MultitaskMultivariateNormal`): Random variable whose covariance
                matrix is a :obj:`gpytorch.lazy.LazyTensor` we intend to augment.
        Returns:
            :obj:`gpytorch.distributions.MultitaskMultivariateNormal`: A new random variable whose covariance
            matrix is a :obj:`gpytorch.lazy.LazyTensor` with :math:`D_{t} \otimes I_{n}` and :math:`\sigma^{2}I_{nt}`
            added.
        """ # Make sure the batch sizes are going to match
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.

To accomplish this, we form a new :obj:`gpytorch.lazy.KroneckerProductLazyTensor` between :math:`I_{n}`,
an identity matrix with size equal to the data and a (not necessarily diagonal) matrix containing the task
noises :math:`D_{t}`.

We also incorporate a shared `noise` parameter from the base
` gpytorch . distributions . MultivariateNormal ` or : obj : ` gpytorch . distributions . MultitaskMultivariateNormal ` in case of ` rank ` == 0 . Otherwise adds a rank ` rank ` covariance matrix to it . To accomplish this we form a new : obj : ` gpytorch . lazy . KroneckerProductLazyTensor ` between : math : ` I_ { n } ` an identity matrix with size equal to the data and a ( not necessarily diagonal ) matrix containing the task noises : math : ` D_ { t } ` . We also incorporate a shared ` noise ` parameter from the base
class
`gpytorch.likelihoods.GaussianLikelihood` that we extend.
The final covariance matrix after this method is then :math:`K + D_{t} \otimes I_{n} + \sigma^{2}I_{nt}`.

input (:obj:`gpytorch.distributions.MultitaskMultivariateNormal`): Random variable whose covariance
matrix is a :obj:`gpytorch.lazy.LazyTensor` we intend to augment.
Returns:
:obj:`gpytorch.distributions.MultitaskMultivariateNormal`: A new random variable whose covariance
matrix is a :obj:`gpytorch.lazy.LazyTensor` with :math:`D_{t} \otimes I_{n}` and :math:`\sigma^{2}I_{nt}`
added.
` gpytorch . likelihoods . GaussianLikelihood ` that we extend . The final covariance matrix after this method is then : math : ` K + D_ { t } \ otimes I_ { n } + \ sigma^ { 2 } I_ { nt } ` . input ( : obj : ` gpytorch . distributions . MultitaskMultivariateNormal ` ) : Random variable whose covariance matrix is a : obj : ` gpytorch . lazy . LazyTensor ` we intend to augment . Returns : : obj : ` gpytorch . distributions . MultitaskMultivariateNormal ` : A new random variable whose covariance matrix is a : obj : ` gpytorch . lazy . LazyTensor ` with : math : ` D_ { t } \ otimes I_ { n } ` and : math : ` \ sigma^ { 2 } I_ { nt } ` added .