LocalResponseNorm

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

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)
Lateral Inhibition Mechanism
LocalResponseNorm activations
Local Response Normalization (LRN) implements a form of lateral inhibition inspired by biological neurons. It normalizes a pixel's value based on the activity of its neighbors in the channel dimension, historically used in AlexNet to improve generalization.