(self, x)
return weights
Perform forward pass.

        Parameters
        ----------
        x : torch.Tensor
            Of shape (n_samples, n_channels, lookback, n_assets). The last 3 dimensions need to be of the same
            size as specified in the constructor. They cannot vary.

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

        Parameters
        ----------
        x : torch.Tensor
            Of shape (n_samples, n_channels, lookback, n_assets). The last 3 dimensions need to be of the same
            size as specified in the constructor. They cannot vary.

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

        """
        if x.shape[1:] != (self.n_channels, self.lookback, self.n_assets):
            raise ValueError('Input x has incorrect shape {}'.format(x.shape))

        n_samples, _, _, _ = x.shape

        # Normalize
        x = x.view(n_samples, -1)  # flatten
        x = self.norm_layer(x)
        x = self.dropout_layer(x)
        x = self.linear(x)

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

        return weights
def forward ( self , x ) : if x . shape [ 1 : ] != ( self . n_channels , self . lookback , self . n_assets ) : raise ValueError ( 'Input x has incorrect shape {}' . format ( x . shape ) ) n_samples , _ , _ , _ = x . shape # Normalize x = x . view ( n_samples , - 1 ) # flatten x = self . norm_layer ( x ) x = self . dropout_layer ( x ) x = self . linear ( x ) temperatures = torch . ones ( n_samples ) . to ( device = x . device , dtype = x . dtype ) * self . temperature weights = self . allocate_layer ( x , temperatures ) return weights