torch.nn.AdaptiveAvgPool1d
class AdaptiveAvgPool1d extends Modulenew AdaptiveAvgPool1d(output_size: number)
- readonly
output_size(number)
1D adaptive average pooling: reduces sequence to fixed output size with smooth averaging.
Similar to AdaptiveMaxPool1d but uses average instead of max. Produces fixed output_size by automatically computing kernel_size and stride, then averaging within each region. Smoother downsampling than max pooling, retaining more information.
- Smooth downsampling: Averages instead of taking max (less information loss)
- Fixed output: Always produces output_size elements
- Variable input: Works with any input sequence length
Examples
// Variable-length sequences to fixed size with smooth averaging
const pool = new torch.nn.AdaptiveAvgPool1d(10);
const x1 = torch.randn([32, 64, 100]);
const y1 = pool.forward(x1); // [32, 64, 10] - averaged
const x2 = torch.randn([32, 64, 50]);
const y2 = pool.forward(x2); // [32, 64, 10] - same output size