torch.nn.LPPool2d
new LPPool2d(norm_type: number, kernel_size: number | [number, number], options?: LPPool2dOptions)
- readonly
norm_type(number) - readonly
kernel_size(number | [number, number]) - readonly
stride(number | [number, number]) - readonly
ceil_mode(boolean)
2D Lp-norm pooling: reduces spatial dimensions using Lp-norm instead of max or mean.
Applies 2D spatial pooling using Lp-norm. Generalized pooling between max and average.
- L1: Sum of absolute values
- L2: Euclidean norm (sqrt of sum of squares) Provides middle ground between extreme max pooling and smooth average pooling.
- Robust pooling: Between max (outlier-sensitive) and mean (smooths)
- L2 common: Euclidean norm most frequently used
- Spatial dimensions: Applies to height and width independently
Examples
// L2 (Euclidean) norm pooling on images
const pool = new torch.nn.LPPool2d(2, 3); // L2-norm, kernel=3x3
const x = torch.randn([32, 64, 224, 224]);
const y = pool.forward(x); // 2D Euclidean norm pooling