输入是3×3矩阵,卷积核/过滤器是2×2矩阵
import numpy as np
input = np.array([[0, 1, 2], [3, 4, 5], [6, 7, 8]])
kernel = np.array([[0, 1], [2, 3]])
hi, wi = input.shape
hk, wk = kernel.shape
ho = hi-hk+1
wo = wi-wk+1
output = np.zeros((ho,wo))
for i in range(ho):
for j in range(wo):
print(input[i:i+wk,j:j+hk])
output[i][j]=np.sum(input[i:i+wk,j:j+hk]*kernel)
print(output)