NumPy allowed · plain Python earns 10 bonus points
Implement a 2D spatial convolution operation from scratch without external libraries, the core layer in CNN architectures.
Implement convolve2d(image, kernel). Apply the kernel across all valid positions without padding. Output dimension is (H - Kh + 1) x (W - Kw + 1).
convolve2d(image: list[list[float]], kernel: list[list[float]]) -> list[list[float]]