(self, x)
return weights
Perform forward pass.

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

        Returns
        -------
        weights : torch.Torch
            Tensor of shape (n_samples, n_assets).
Perform forward pass.
Perform forward pass .
def __call__(self, x):
        """Perform forward pass.

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

        Returns
        -------
        weights : torch.Torch
            Tensor of shape (n_samples, n_assets).

        """
        n_samples, n_channels, lookback, n_assets = x.shape

        x = self.norm_layer_1(x)
        if self.transform_type == 'RNN':
            x = self.transform_layer(x)
        else:
            x = torch.stack([self.transform_layer(x[..., i]) for i in range(n_assets)], dim=-1)

        x = self.norm_layer_2(x)
        x = torch.nn.functional.relu(x)
        x = self.time_collapse_layer(x)
        x = self.channel_collapse_layer(x)

        temperatures = torch.ones(n_samples).to(device=x.device, dtype=x.dtype) * self.temperature

        weights = self.portfolio_opt_layer(x, temperatures)

        return weights
def __call__ ( self , x ) : n_samples , n_channels , lookback , n_assets = x . shape x = self . norm_layer_1 ( x ) if self . transform_type == 'RNN' : x = self . transform_layer ( x ) else : x = torch . stack ( [ self . transform_layer ( x [ ... , i ] ) for i in range ( n_assets ) ] , dim = - 1 ) x = self . norm_layer_2 ( x ) x = torch . nn . functional . relu ( x ) x = self . time_collapse_layer ( x ) x = self . channel_collapse_layer ( x ) temperatures = torch . ones ( n_samples ) . to ( device = x . device , dtype = x . dtype ) * self . temperature weights = self . portfolio_opt_layer ( x , temperatures ) return weights