AvgPool1d

https://pytorch.org/docs/stable/generated/torch.nn.AvgPool1d.html

avgpool1d_demo.py
import svetoviz_webgpu as sv

# 1. Create a synthetic 1D signal (e.g., a noisy sine wave)
t = torch.linspace(0, 10, 100)
signal = torch.sin(t) + torch.randn(100) * 0.2
# Shape: (Batch=1, Channels=1, Length=100)
input_tensor = signal.unsqueeze(0).unsqueeze(0)

# 2. Define AvgPool1d
# Kernel size 4 smooths the signal by averaging every 4 adjacent points
pool1d = nn.AvgPool1d(kernel_size=4, stride=4)

def terminal_callback(buffer, message, images, files):
    # 3. Process the signal through the module
    output = pool1d(input_tensor)

    buffer.send_system_message(f"Input Signal: {list(input_tensor.shape)}")
    buffer.send_system_message(f"Smoothed Signal (Avg): {list(output.shape)}")

# 4. Start the interactive session
sv.pytorch_web(module=pool1d, terminal_callback=terminal_callback)
Temporal Signal Averaging
AvgPool1d activations
Unlike MaxPool, AvgPool considers all values in the window, resulting in a smoother, low-pass filtered signal.