(self, x, shrinkage_coef=None)
return torch.stack([wrapper(self.compute_covariance(x[i].T.clone(),
                                                            shrinkage_strategy=self.shrinkage_strategy,
                                                            shrinkage_coef=shrinkage_coef_[i]))
                            for i in range(n_samples)], dim=0)
Perform forward pass.

        Parameters
        ----------
        x : torch.Tensor
            Of shape (n_samples, dim, n_assets). The middle dimension `dim`
            represents the observations we compute the covariance matrix over.

        shrinkage_coef : None or torch.Tensor
            If None then using the `self.shrinkage_coef` supplied at construction for each sample. Otherwise a
            tensor of shape `(n_shapes,)`.

        Returns
        -------
        covmat : torch.Tensor
            Of shape (n_samples, n_assets, n_assets).
Perform forward pass.
Perform forward pass .
def forward(self, x, shrinkage_coef=None):
        """Perform forward pass.

        Parameters
        ----------
        x : torch.Tensor
            Of shape (n_samples, dim, n_assets). The middle dimension `dim`
            represents the observations we compute the covariance matrix over.

        shrinkage_coef : None or torch.Tensor
            If None then using the `self.shrinkage_coef` supplied at construction for each sample. Otherwise a
            tensor of shape `(n_shapes,)`.

        Returns
        -------
        covmat : torch.Tensor
            Of shape (n_samples, n_assets, n_assets).

        """
        n_samples = x.shape[0]
        dtype, device = x.dtype, x.device

        if not ((shrinkage_coef is None) ^ (self.shrinkage_coef is None)):
            raise ValueError('Not clear which shrinkage coefficient to use')

        if shrinkage_coef is not None:
            shrinkage_coef_ = shrinkage_coef  # (n_samples,)
        else:
            shrinkage_coef_ = self.shrinkage_coef * torch.ones(n_samples, dtype=dtype, device=device)

        wrapper = self.compute_sqrt if self.sqrt else lambda h: h

        return torch.stack([wrapper(self.compute_covariance(x[i].T.clone(),
                                                            shrinkage_strategy=self.shrinkage_strategy,
                                                            shrinkage_coef=shrinkage_coef_[i]))
                            for i in range(n_samples)], dim=0)
def forward ( self , x , shrinkage_coef = None ) : n_samples = x . shape [ 0 ] dtype , device = x . dtype , x . device if not ( ( shrinkage_coef is None ) ^ ( self . shrinkage_coef is None ) ) : raise ValueError ( 'Not clear which shrinkage coefficient to use' ) if shrinkage_coef is not None : shrinkage_coef_ = shrinkage_coef # (n_samples,) else : shrinkage_coef_ = self . shrinkage_coef * torch . ones ( n_samples , dtype = dtype , device = device ) wrapper = self . compute_sqrt if self . sqrt else lambda h : h return torch . stack ( [ wrapper ( self . compute_covariance ( x [ i ] . T . clone ( ) , shrinkage_strategy = self . shrinkage_strategy , shrinkage_coef = shrinkage_coef_ [ i ] ) ) for i in range ( n_samples ) ] , dim = 0 )