LPPool1d

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

lppool1d_demo.py
import svetoviz_webgpu as sv

# 1. Create a synthetic 1D signal
t = torch.linspace(0, 10, 100)
signal = torch.sin(t) + torch.randn(100) * 0.2
input_tensor = signal.unsqueeze(0).unsqueeze(0)

# 2. Define LPPool1d
# norm_type (p) = 2 (Euclidean norm)
# If p=1, it is sum pooling; as p increases, it approaches max pooling.
pool1d = nn.LPPool1d(norm_type=2, 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"L2 Pooled Signal (p=2): {list(output.shape)}")

# 4. Start the interactive session
sv.pytorch_web(module=pool1d, terminal_callback=terminal_callback)
Power Pooling (p-norm)
LPPool1d activations
LPPool provides a middle ground between average pooling (p=1) and max pooling (p=∞), emphasizing stronger activations via the L2 norm.