local_response_norm_demo.py
import svetoviz_webgpu as sv
# 1. Define Normalization Parameters
# size: number of neighboring channels to include in the window
lrn = nn.LocalResponseNorm(size=2, alpha=1e-4, beta=0.75, k=1.0)
# 2. Prepare Input Tensor (Batch=1, Channels=3, H, W)
input_tensor = torch.from_numpy(img_np).permute(2, 0, 1).unsqueeze(0)
def terminal_callback(buffer, message, images, files):
output = lrn(input_tensor)
buffer.send_system_message(f"Input Channels: {input_tensor.shape[1]}")
buffer.send_system_message(f"Neighborhood Size: {lrn.size}")
buffer.send_system_message("Logic: Lateral inhibition applied across the channel dimension.")
# 3. Start the interactive session
sv.pytorch_web(module=lrn, terminal_callback=terminal_callback)