from mxnet import init, np, npx
from mxnet.gluon import nn
from d2l import mxnet as d2l
npx.set_np()
def trans_conv(X, K):
h, w = K.shape
Y = np.zeros((X.shape[0] + h - 1, X.shape[1] + w - 1))
for i in range(X.shape[0]):
for j in range(X.shape[1]):
Y[i: i + h, j: j + w] += X[i, j] * K
return Y
X = np.array([[1.0,2.0], [4.0, 3.0]])
K = np.array([[4.0, 3.0], [1.0,2.0]])
trans_conv(X, K)
突然感觉不敢运行,哈哈哈