惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
爱范儿
爱范儿
博客园_首页
博客园 - 【当耐特】
V
Visual Studio Blog
博客园 - 叶小钗
月光博客
月光博客
美团技术团队
J
Java Code Geeks
小众软件
小众软件
Y
Y Combinator Blog
博客园 - Franky
Martin Fowler
Martin Fowler
博客园 - 聂微东
Microsoft Azure Blog
Microsoft Azure Blog
IT之家
IT之家
MyScale Blog
MyScale Blog
人人都是产品经理
人人都是产品经理
Microsoft Security Blog
Microsoft Security Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
阮一峰的网络日志
阮一峰的网络日志
酷 壳 – CoolShell
酷 壳 – CoolShell
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
云风的 BLOG
云风的 BLOG

Show HN

GitHub - astefanutti/shaderbang: Shebang for Shaders Show HN: Generate Claude Code Workflows using Spec Driven Development approach Show HN: AI agents for UK GDAD PCF roles and their skills The Two Pillars: Mixer Mode and Meta-Software in the Reorganization of Software Work After AI GitHub - JaiCode08/teleport-env What 1,000+ Harness Experiments Taught Me About Self-Improving Agents Show HN: Liiists, a Markdown-first, iOS and CLI list app SwiperTab – Get this Extension for 🦊 Firefox (en-US) GitHub - kouhxp/fftext: Summarize, explain, fact-check, or translate any text, URL, or file. No GPU. No cloud. One command GitHub - sweetpad-dev/sweetpad: Develop Swift/iOS projects using VSCode GitHub - dogmaticdev/IRON: IRON a.k.a. Intermediate Representation Object Notation is a Interpreter/Database that is used to create Programming Languages. GitHub - sjhalani7/vaen: Package your AI coding harness into a portable .agent file, and share it across repos, teams, & the community without ever having to copy-paste instructions, skills, MCP config, or secrets. Show HN: Gandalf the Grader Show HN: Citadeld – replay any CI failure locally from a single file GitHub - tdortman/cuSBF: High-Performance GPU Super Bloom Filter coral-ai/claude-code-token-xray at main · Coral-Bricks-AI/coral-ai GitHub - ulyssestenn/funes: Funes is a Git-based framework for LLM-managed knowledge work: an AI Librarian ingests raw sources, builds an interlinked Markdown knowledge base, and uses it to produce cited reports, analyses, and other outputs. GitHub - ThatXliner/gah: Git Add Hunk, built for agents to use GitHub - harmont-dev/harmont-cli: Command-line client for the Harmont CI platform GitHub - brooksmcmillin/mcp-authflow: OAuth 2.0 Authorization Server framework for MCP servers GitHub - javaid-codes/audit-supply-chain-agents GitHub - amorey/gochan: A small library of common channel architectures for Go, inspired by Rust GitHub - arifozgun/OpenGem: Free, Open-Source AI API Gateway with Gemini, OpenAI & Anthropic Compatibility in 1 file GitHub - Pranesh950/BioPetals: 🌸 Run BIOxAI models at home, BitTorrent-style. Fine-tuning and inference up to 10x faster than offloading GitHub - cnguyen14/bounty-doctor: Diagnose a GitHub bounty issue before you waste hours: detects honeypot scam repos, AI-bot attempt swarms, and stale contests. Show HN: CoreMCP – MCP Server for On-Prem DBs Show HN: KittyHTML – Render HTML/CSS as an inline image in your terminal GitHub - bingud/filemat: Web-based file manager Show HN: TruthLens – Free multi-signal deepfake image detector GitHub - apexlocal-jz/claude-usage-tray: Windows system-tray app showing your Claude Code rate-limit usage at a glance. Zero deps, ~300 lines of PowerShell. Cross-IDE (works regardless of VS Code, Cursor, plain terminal).
GitHub - singam96/ReflexConv2D: A conv layer that modulat...
singam96 · 2026-06-24 · via Show HN

A convolutional layer that modulates its own output using a mask made from its own weights, with a residual skip connection.

Problem

Standard convolutions apply the same filter uniformly across the entire spatial domain. In image-to-image tasks (autoencoders, U-Nets), this spatial uniformity contributes to over-smoothed, blurry outputs — the model cannot selectively sharpen or attenuate features at different spatial locations.

Solution

ReflexConv2d lets each layer modulate its own output spatially using a mask extracted from its convolution weights, then adds a residual connection to preserve the input signal.

Step Operation Shape
1 Depthwise-like C→C convolution (B, C, H, W)
2 Sum weights across input channels × learnable squash (C, k, k)
3 Tile each k×k mask to H×W (C, H, W)
4 Elementwise multiply mask onto conv output (B, C, H, W)
5 1×1 pointwise projection (B, C', H, W)
6 Add residual skip (1×1 conv or identity) (B, C', H, W)

The spatial mask is globally learned (via squash and the conv weights) but shared across all input positions — the tiling preserves the kernel's internal structure without interpolation artifacts.

Result

In a U-Net autoencoder benchmark (both paths use residual skip connections), ReflexConv2d outperforms standard convolutions at every round of recursive encoding/decoding. Trained on Flick8k samples.

comparison

Rounds Standard Reflex Improvement
L1 ↓ PSNR ↑ L1 ↓ PSNR ↑ L1 PSNR SSIM ↑
1 0.1134 16.23 0.0933 17.97 17.7% +1.7 dB 0.64 → 0.74
2 0.1458 13.62 0.1114 16.49 23.6% +2.9 dB 0.54 → 0.66
4 0.2196 8.85 0.1416 14.37 35.5% +5.5 dB 0.40 → 0.53
8 0.4441 1.40 0.1887 11.86 57.5% +10.5 dB 0.22 → 0.37

The weight-derived mask preserves structure through repeated encoding — the model retains detail where standard convolutions degrade. The advantage grows with each recursive pass.

Ablation

What happens when we remove components?

ablation

Config L1 @ R8 PSNR @ R8 SSIM @ R8
Standard + Residual 0.4441 1.40 dB 0.22
Reflex − Residual 0.2718 (−39%) 8.50 dB 0.28
Reflex − Squash 0.1896 (−57%) 12.02 dB 0.32
Reflex Full 0.1887 (−57%) 11.86 dB 0.37
  • Residual helps — Full reflex (0.1887) beats no-residual reflex (0.2718), but even without residual, reflex still beats standard (0.4441)
  • Squash has minimal impact — Removing it (0.1896) performs nearly identically to full reflex (0.1887). The raw kernel sum is the real signal

Install

pip install git+https://github.com/singam96/ReflexConv2D.git

Usage

import torch
from reflex_conv2d import ReflexConv2d

layer = ReflexConv2d(in_channels=64, out_channels=128, kernel_size=3)
x = torch.randn(4, 64, 32, 32)
y = layer(x)                # (4, 128, 32, 32)

Drop it into any model:

nn.Sequential(
    ReflexConv2d(3, 64, 3),
    nn.ReLU(),
    ReflexConv2d(64, 64, 3),
    nn.ReLU(),
    ...
)

Reproduce

# Run full ablation study (trains 4 models, generates images + metrics)
python benchmark.py

# Run main comparison only
python demo_comparison.py

Outputs:

  • comparison.jpg — standard vs reflex visual comparison
  • ablation_grid.jpg — all ablation configs side by side
  • ablation_*.jpg — individual ablation result images
  • Console metrics (L1, PSNR, SSIM per round)

Test

pip install pytest
python -m pytest test_reflex_conv2d.py

Notes

  • The squash parameter (C scalars initialized to 1) lets the network selectively disable self-modulation on any channel.
  • Residual skip uses nn.Identity when in_channels == out_channels, otherwise a 1×1 conv to match dimensions.
  • Odd kernel sizes only (1, 3, 5, 7, ...). Even kernels shift spatial dimensions due to asymmetric padding.
  • Negligible parameter increase over standard Conv2d(C, C', k): C (squash) + skip conv when channels differ.

License

Apache 2.0