I am currently trying to implement the backward pass of a convolution layer by hand but I am struggling to get the gradient dL/dW working.
This is my current approach:
for b in range(B):
for c in range(IN_C):
for k in range(K_K):
ERROR = error_tensor[b, k]
INP = self.previous_input[b, c]
INP = np.pad(INP, ((K_W // 2, K_W // 2), (K_H // 2, K_H // 2)))
CONV_WEIGHTS = signal.convolve2d(INP, ERROR, mode='valid')
WEIGHT_GRADIENT[k, c] += CONV_WEIGHTS
where B is the Batch-Size dimension, K_W the width of the kernel, K_H the height of the kernel, IN_C the number of channels of the input from the forward pass and K_K the number of kernels.
Somehow this doesn't work out so I guess I am doing something wrong.
Can someone give me a hint?