MaxPool1d

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

maxpool1d_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 MaxPool1d
# Kernel size 4 reduces the resolution by taking the max of every 4 points
pool1d = nn.MaxPool1d(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"Downsampled Signal: {list(output.shape)}")

# 4. Start the interactive session
sv.pytorch_web(module=pool1d, terminal_callback=terminal_callback)
Temporal Max Selection
MaxPool1d activations
Select an output point to see the local maximum selected from the input window.