(self, x, temperature=None)
return self.layer(inp) if self.formulation == 'analytical' else self.layer(inp)[0]
Perform forward pass.

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

        temperature : None or torch.Tensor
            If None, then using the `temperature` provided at construction time. Otherwise a `torch.Tensor` of shape
            `(n_samples,)` representing a per sample temperature.

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

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

        temperature : None or torch.Tensor
            If None, then using the `temperature` provided at construction time. Otherwise a `torch.Tensor` of shape
            `(n_samples,)` representing a per sample temperature.

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

        """
        n_samples, _ = x.shape
        device, dtype = x.device, x.dtype

        if not ((temperature is None) ^ (self.temperature is None)):
            raise ValueError('Not clear which temperature to use')

        if temperature is not None:
            temperature_ = temperature  # (n_samples,)
        else:
            temperature_ = float(self.temperature) * torch.ones(n_samples, dtype=dtype, device=device)

        inp = x / temperature_[..., None]

        return self.layer(inp) if self.formulation == 'analytical' else self.layer(inp)[0]
def forward ( self , x , temperature = None ) : n_samples , _ = x . shape device , dtype = x . device , x . dtype if not ( ( temperature is None ) ^ ( self . temperature is None ) ) : raise ValueError ( 'Not clear which temperature to use' ) if temperature is not None : temperature_ = temperature # (n_samples,) else : temperature_ = float ( self . temperature ) * torch . ones ( n_samples , dtype = dtype , device = device ) inp = x / temperature_ [ ... , None ] return self . layer ( inp ) if self . formulation == 'analytical' else self . layer ( inp ) [ 0 ]