def bilinear_kernel_2D(ratio, normalize=True):
 hkern = bilinear_kernel_1D(ratio=ratio, normalize=normalize).dimshuffle('x', 0)
 vkern = bilinear_kernel_1D(ratio=ratio, normalize=normalize).dimshuffle(0, 'x')
 kern = (hkern * vkern)
 return kern

def bilinear_kernel_2D ( ratio , normalize = True ) : hkern = bilinear_kernel_1D ( ratio = ratio , normalize = normalize ) . dimshuffle ( 'x' , 0 ) vkern = bilinear_kernel_1D ( ratio = ratio , normalize = normalize ) . dimshuffle ( 0 , 'x' ) kern = ( hkern * vkern ) return kern
compute 2d kernel for bilinear upsampling this function builds the 2d kernel that can be used to upsample a tensor by the given ratio using bilinear interpolation .