(self, x)
return weights_filled
Perform forward pass.

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

        Returns
        -------
        weights_filled : torch.Tensor
            Of shape (n_samples, n_assets) representing the optimal weights as determined by the
            convex optimizer.
Perform forward pass.
Perform forward pass .
def forward(self, x):
        """Perform forward pass.

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

        Returns
        -------
        weights_filled : torch.Tensor
            Of shape (n_samples, n_assets) representing the optimal weights as determined by the
            convex optimizer.

        """
        n = len(x)

        cov_sqrt = torch.mm(self.matrix, torch.t(self.matrix)) if self.force_symmetric else self.matrix

        weights = self.portfolio_opt_layer(self.exp_returns[None, ...],
                                           cov_sqrt[None, ...],
                                           self.gamma_sqrt,
                                           torch.zeros(1).to(device=x.device, dtype=x.dtype))
        weights_filled = torch.repeat_interleave(weights, n, dim=0)

        return weights_filled
def forward ( self , x ) : n = len ( x ) cov_sqrt = torch . mm ( self . matrix , torch . t ( self . matrix ) ) if self . force_symmetric else self . matrix weights = self . portfolio_opt_layer ( self . exp_returns [ None , ... ] , cov_sqrt [ None , ... ] , self . gamma_sqrt , torch . zeros ( 1 ) . to ( device = x . device , dtype = x . dtype ) ) weights_filled = torch . repeat_interleave ( weights , n , dim = 0 ) return weights_filled