# flambe.nn.pooling¶

## Module Contents¶

class flambe.nn.pooling.FirstPooling[source]

Get the last hidden state of a sequence.

forward(self, data: torch.Tensor, padding_mask: Optional[torch.Tensor] = None)[source]

Performs a forward pass.

Parameters: data (torch.Tensor) – The input data, as a tensor of shape [B x S x H] padding_mask (torch.Tensor) – The input mask, as a tensor of shape [B X S] The output data, as a tensor of shape [B x H] torch.Tensor
class flambe.nn.pooling.LastPooling[source]

Get the last hidden state of a sequence.

forward(self, data: torch.Tensor, padding_mask: Optional[torch.Tensor] = None)[source]

Performs a forward pass.

Parameters: data (torch.Tensor) – The input data, as a tensor of shape [B x S x H] padding_mask (torch.Tensor) – The input mask, as a tensor of shape [B X S] The output data, as a tensor of shape [B x H] torch.Tensor
class flambe.nn.pooling.SumPooling[source]

Get the sum of the hidden state of a sequence.

forward(self, data: torch.Tensor, padding_mask: Optional[torch.Tensor] = None)[source]

Performs a forward pass.

Parameters: data (torch.Tensor) – The input data, as a tensor of shape [B x S x H] padding_mask (torch.Tensor) – The input mask, as a tensor of shape [B X S] The output data, as a tensor of shape [B x H] torch.Tensor
class flambe.nn.pooling.AvgPooling[source]

Get the average of the hidden state of a sequence.

forward(self, data: torch.Tensor, padding_mask: Optional[torch.Tensor] = None)[source]

Performs a forward pass.

Parameters: data (torch.Tensor) – The input data, as a tensor of shape [B x S x H] padding_mask (torch.Tensor) – The input mask, as a tensor of shape [B X S] The output data, as a tensor of shape [B x H] torch.Tensor