tirank.Model.TransformerEncoderModel

class tirank.Model.TransformerEncoderModel(*args: Any, **kwargs: Any)[source]

Bases: Module

Transformer-based encoder network.

Parameters:
  • n_features (int) – Input feature size (number of gene pairs).

  • nhead (int) – Number of heads in the multi-head attention models.

  • nhid (int) – Dimension of the feedforward network model.

  • nlayers (int) – Number of sub-encoder-layers in the encoder.

  • n_output (int) – Output embedding dimension.

  • dropout (float, optional) – Dropout value. Defaults to 0.5.

init_weights()[source]

Initializes weights for the linear layers.

forward(x)[source]

Forward pass for the Transformer encoder.

Parameters:

x (torch.Tensor) – Input feature tensor.

Returns:

Output embedding tensor.

Return type:

torch.Tensor