Skip to content

Max Pool

torchmil.nn.MaxPool

Bases: Module

Max pooling aggregation.

Given an input bag \(\mathbf{X} = \left[ \mathbf{x}_1, \ldots, \mathbf{x}_N \right]^\top \in \mathbb{R}^{N \times D}\), this model aggregates the instance features into a bag representation \(\mathbf{z} \in \mathbb{R}^{D}\) as,

\[ \left[ \mathbf{z} \right]_d = \max \left\{ \left[ \mathbf{x}_n \right]_{d} \ \colon n \in \left\{ 1, \ldots, N \right\} \right\}, \]

where \(\left[ \mathbf{a} \right]_i\) denotes the \(i\)-th element of the vector \(\mathbf{a}\).

__init__()
forward(X, mask=None)

Parameters:

  • X (Tensor) –

    Input tensor of shape (batch_size, bag_size, in_dim).

  • mask (Tensor, default: None ) –

    Mask tensor of shape (batch_size, bag_size).

Returns:

  • z ( Tensor ) –

    Output tensor of shape (batch_size, in_dim).