(self, x)
return weights
Predict weights.

        Parameters
        ----------
        x : torch.Tensor
            Tensor of shape `(n_samples, n_channels, lookback, n_assets)`.

        Returns
        -------
        weights : torch.Tensor
            Tensor of shape `(n_samples, n_assets)` representing the predicted weights.
Predict weights.
Predict weights .
def __call__(self, x):
        """Predict weights.

        Parameters
        ----------
        x : torch.Tensor
            Tensor of shape `(n_samples, n_channels, lookback, n_assets)`.

        Returns
        -------
        weights : torch.Tensor
            Tensor of shape `(n_samples, n_assets)` representing the predicted weights.

        """
        eps = 1e-6
        x_rets = x[:, self.returns_channel, ...]
        vols = x_rets.std(dim=1) if self.use_std else x_rets.var(dim=1)
        ivols = 1 / (vols + eps)
        weights = ivols / ivols.sum(dim=1, keepdim=True)

        return weights
def __call__ ( self , x ) : eps = 1e-6 x_rets = x [ : , self . returns_channel , ... ] vols = x_rets . std ( dim = 1 ) if self . use_std else x_rets . var ( dim = 1 ) ivols = 1 / ( vols + eps ) weights = ivols / ivols . sum ( dim = 1 , keepdim = True ) return weights