(self, weights, y)
return ((weights - cumrets.softmax(dim=1)) ** 2).sum(dim=1)
Compute softmax loss.

        Parameters
        ----------
        weights : torch.Tensor
            Tensor of shape `(n_samples, n_assets)` representing the predicted weights by our portfolio optimizer.

        y : torch.Tensor
            Tensor of shape `(n_samples, n_channels, horizon, n_assets)` representing the evolution over the next
            `horizon` timesteps.

        Returns
        -------
        torch.Tensor
            Tensor of shape `(n_samples,)` representing the per sample negative worst return over the horizon.
Compute softmax loss.
Compute softmax loss .
def __call__(self, weights, y):
        """Compute softmax loss.

        Parameters
        ----------
        weights : torch.Tensor
            Tensor of shape `(n_samples, n_assets)` representing the predicted weights by our portfolio optimizer.

        y : torch.Tensor
            Tensor of shape `(n_samples, n_channels, horizon, n_assets)` representing the evolution over the next
            `horizon` timesteps.

        Returns
        -------
        torch.Tensor
            Tensor of shape `(n_samples,)` representing the per sample negative worst return over the horizon.

        """
        cumrets = y[:, self.returns_channel, ...].sum(dim=1)

        return ((weights - cumrets.softmax(dim=1)) ** 2).sum(dim=1)
def __call__ ( self , weights , y ) : cumrets = y [ : , self . returns_channel , ... ] . sum ( dim = 1 ) return ( ( weights - cumrets . softmax ( dim = 1 ) ) ** 2 ) . sum ( dim = 1 )