fn
adaptive_max_pool2d
→Tensoradaptive_max_pool2d(x: Tensor, output_size: int | tuple[int, int], return_indices: bool = False)2-D adaptive max pooling — fixed-shape (H, W) via per-cell max.
Like adaptive_avg_pool2d but takes the maximum over each
dynamically computed window instead of the mean. Useful when
salient peaks should drive the downstream representation
(e.g. object detectors that rely on strong activations).
Parameters
xTensorInput of shape
(N, C, H, W).output_sizeint or (int, int)Desired spatial output shape.
return_indicesbool= FalseMust currently be
False.Returns
TensorOutput of shape (N, C, oH, oW).
Notes
For each output cell, the window definition is the same as in
adaptive_avg_pool2d; the cell value is
Gradient flows only through the per-window argmax position.
Examples
>>> import lucid
>>> from lucid.nn.functional import adaptive_max_pool2d
>>> x = lucid.randn(1, 64, 11, 13)
>>> y = adaptive_max_pool2d(x, output_size=(3, 3))
>>> y.shape
(1, 64, 3, 3)