(self, weights, y)
return mapping(prets.mean(dim=1))
Compute distance from the target return.

        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 mean returns.
Compute distance from the target return.
Compute distance from the target return .
def __call__(self, weights, y):
        """Compute distance from the target return.

        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 mean returns.

        """

        def mapping(x):
            return abs(x - self.target) ** self.p

        prets = portfolio_returns(weights,
                                  y[:, self.returns_channel, ...],
                                  input_type=self.input_type,
                                  output_type=self.output_type)

        return mapping(prets.mean(dim=1))
def __call__ ( self , weights , y ) : def mapping ( x ) : return abs ( x - self . target ) ** self . p prets = portfolio_returns ( weights , y [ : , self . returns_channel , ... ] , input_type = self . input_type , output_type = self . output_type ) return mapping ( prets . mean ( dim = 1 ) )