在卷积神经网络中实施填充是一件十分重要的事情,如果没有填充,边缘区域的像素值基本不会受到卷积层的影响。
那么,如何写填充代码:
# if you want to pad the array "a" of shape (5,5,5,5,5)(5,5,5,5,5) with pad = 1 for the 2nd dimension,
# pad = 3 for the 4th dimension and pad = 0 for the rest, you would do
a = np.pad(a, ((0,0), (1,1), (0,0), (3,3), (0,0)), 'constant', constant_values = (..,..))