Can have a big analysis under the convolution in the network this code, very grateful!
Def bilinear_kernel (in_channels, out_channels kernel_size) :
Factor=(kernel_size + 1)//2
If kernel_size % 2==1:
Center=factor - 1
The else:
Center=factor - 0.5
Og=np. Ogrid [kernel_size, : kernel_size]
Filt waste=(1 - abs (og [0] - center)/factor) * \
(1 - abs (og [1] - center)/factor)
Weight=np. Zeros ((in_channels out_channels, kernel_size, kernel_size),
='float32' dtype)
Weight [range (in_channels), range (out_channels), :, :]=filt waste
Return the torch. From_numpy (np) array (weight))