The mechanism
A convolutional layer shares a local kernel across spatial locations. The same coefficients can detect a similar pattern in more than one place, while stride, padding and kernel size determine which positions are seen. Patch attention instead calculates weights from the relationship between a query and candidate patches; those weights depend on input content. Both methods process structured arrays, but their connectivity and computation differ. The specimen uses a generated 5×5 line image, two authored 3×3 line filters and one query drawn from the center image patch. Its small arithmetic makes boundary effects and input-dependent attention visible. It deliberately separates a hand-built filter classifier from learned visual representations: fitting and evaluating a CNN or vision transformer would require training data, trainable projections, task losses and independent outcomes.
- Generate a vertical or horizontal line at one of five positions and optionally erase the middle row.
- Cross-correlate two 3×3 authored filters at each of nine valid locations without padding.
- Use the largest filter responses for an explicit line-orientation decision, retaining ties as ties.
- Flatten nine overlapping patches, score each against the center query with a scaled dot product, normalize and combine their values.
Science and assumptions
Local filters and patch attention · governing computation
Locate the receptive field and identify how local boundary coverage differs from content-dependent aggregation.
Symbols and units
- X
- Five by five input image
pixel amplitude
- K
- Three by three shared kernel
filter coefficient
- Y
- Three by three valid response
weighted amplitude
- i,j
- Output location
pixel index
- u,v
- Kernel coordinate
pixel index
A centered vertical line gives a maximum vertical-filter response of 3 and horizontal response of 1, so the simple classifier returns vertical. At the outermost column, valid convolution never centers its vertical filter there; the maximum vertical response becomes 0 while horizontal response is 1. The wrong label follows from the stated coverage, not from an invented accuracy score. Two filters × nine output positions × nine kernel entries require 162 MACs; nine patch scores × nine coordinates require 81 dot-product MACs before attention normalization and value aggregation.
Assumptions Authored filters and one identity-projection patch query; stride one, no padding; no trained CNN, full ViT, learned positions or recognition benchmark.
Engineering example
A centered vertical line gives a maximum vertical-filter response of 3 and horizontal response of 1, so the simple classifier returns vertical. At the outermost column, valid convolution never centers its vertical filter there; the maximum vertical response becomes 0 while horizontal response is 1. The wrong label follows from the stated coverage, not from an invented accuracy score. Two filters × nine output positions × nine kernel entries require 162 MACs; nine patch scores × nine coordinates require 81 dot-product MACs before attention normalization and value aggregation.
Distinctions and tradeoffs
An attention heatmap is not proof that the model understands an image, and authored filters are not a trained vision model.
Local weight sharing imposes useful spatial structure and bounded receptive fields. Content-dependent aggregation changes connectivity, while padding, tokenization and position handling still matter.
Vision, industrial inspection and multimodal systems turn sampled images into representations through concrete spatial and learned operations.
Specifications and interfaces
- Computational contract
- Compare fixed local receptive fields with content-weighted patch aggregation.
Authored filters and one identity-projection patch query; stride one, no padding; no trained CNN, full ViT, learned positions or recognition benchmark.
- Learning evidence
- Inspectable executable specimen
Inputs, intermediate values, exact output and a declared comparison or failure are available in Contrasting AI mechanisms.
Interfaces
- Specified input Input
- Generate a vertical or horizontal line at one of five positions and optionally erase the middle row.
- Computed output Output
- Locate the receptive field and identify how local boundary coverage differs from content-dependent aggregation.
Check your understanding
Why does the edge-line fixture fail under this valid-convolution classifier?
- The vertical filter is never centered on that outermost column
- All vertical lines are inherently ambiguous
- More attention heads would prove the target label
Answer and reasoning
The vertical filter is never centered on that outermost column
The kernel placement and classifier are explicit. A boundary position outside the selected receptive-field centers can lose the intended filter response.
Evidence and scope
Authored filters and one identity-projection patch query; stride one, no padding; no trained CNN, full ViT, learned positions or recognition benchmark. Numerical settings are original teaching fixtures. The named experience executes the stated bounded algorithm; no production performance or independent human review is claimed.
Authored filters and one identity-projection patch query; stride one, no padding; no trained CNN, full ViT, learned positions or recognition benchmark.