bilinear initialization of deconv layer
sudo-rm-covid19 opened this issue · 3 comments
Hi,
I am not quite sure whether the following initialization of deconv layer is a valid implementation of bilinear filter for all input feature channels:
def fill_up_weights(up):
w = up.weight.data
f = math.ceil(w.size(2) / 2)
c = (2 * f - 1 - f % 2) / (2. * f)
for i in range(w.size(2)):
for j in range(w.size(3)):
w[0, 0, i, j] = \
(1 - math.fabs(i / f - c)) * (1 - math.fabs(j / f - c))
for c in range(1, w.size(0)):
w[c, 0, :, :] = w[0, 0, :, :]
It doesn't initialize w in dim 1 except for the first input channel.
the up
layer is a grouped convolution with the group number equal to the input channels. So the input channel number for each filter is 1.
Got it, thanks!
Hi,
I've got another question why the bilinear initialized kernel not normalized. The norm of the kernel would be 4 if upsampling factor was 2, 16 if upsampling factor was 4 and 64 if upsampling factor was 8.
I used the testing code below:
print(w[0, 0, :, :].sum())
It will amplify the feature values and change the distribution of feature statistics particularly at the earlier stages of training. Does it design on purpose? Will you observe difference results if you changed the initialization method to kaiming normal in or default init or use bn after up sampling conv?
Thanks for your attention