grelu.model.trunks.explainn#

Classes#

ExplaiNNConvBlock

Convolutional block for the ExplaiNN model.

ExplaiNNTrunk

The ExplaiNN model architecture.

Module Contents#

class grelu.model.trunks.explainn.ExplaiNNConvBlock(in_channels: int, out_channels: int, kernel_size: int, groups: int, act_func: str, dropout: float, dtype=None, device=None)[source]#

Bases: torch.nn.Module

Convolutional block for the ExplaiNN model.

Parameters:
  • in_channels – Number of input channels

  • out_channels – Number of output channels

  • kernel_size – Width of the convolutional kernel

  • groups – Number of groups for the convolutional layer

  • act_func – Activation function

  • dropout – Dropout rate

  • dtype – Data type for the layers.

  • device – Device for the layers.

conv[source]#
norm[source]#
act[source]#
dropout[source]#
pool[source]#
flatten[source]#
forward(x: torch.Tensor) torch.Tensor[source]#

Forward pass

Parameters:

x – Input tensor of shape (N, C, L)

Returns:

Output tensor

class grelu.model.trunks.explainn.ExplaiNNTrunk(in_len: int, channels=300, kernel_size=19, dtype=None, device=None)[source]#

Bases: torch.nn.Module

The ExplaiNN model architecture.

Parameters:
  • n_tasks (int) – number of outputs

  • input_length (int) – length of the input sequences

  • channels (int) – number of independent CNN units (default=300)

  • kernel_size (int) – size of each unit’s conv. filter (default=19)

  • dtype – Data type for the layers.

  • device – Device for the layers.

channels[source]#
blocks[source]#
forward(x: torch.Tensor) torch.Tensor[source]#

Forward pass

Parameters:

x – Input tensor of shape (N, C, L)

Returns:

Output tensor