TransForm_Kit/ModelConvert/pytorch2caffe/code/ConvertLayer_caffe.py
def FillBilinear(self,ch, k):
        blob = np.zeros(shape=(ch, 1, k, k))

        """ Create bilinear weights in numpy array """
        bilinear_kernel = np.zeros([k, k], dtype=np.float32)
        scale_factor = (k + 1) // 2
        if k % 2 == 1:
            center = scale_factor - 1
        else:
            center = scale_factor - 0.5
        for x in range(k):
            for y in range(k):
                bilinear_kernel[x, y] = (1 - abs(x - center) / scale_factor) * (1 - abs(y - center) / scale_factor)

        for i in range(ch):
            blob[i, 0, :, :] = bilinear_kernel
        return blob
 Create bilinear weights in numpy array 
Create bilinear weights in numpy array
Create bilinear weights in numpy array
def FillBilinear(self,ch, k):
        blob = np.zeros(shape=(ch, 1, k, k))
        bilinear_kernel = np.zeros([k, k], dtype=np.float32)
        scale_factor = (k + 1) // 2
        if k % 2 == 1:
            center = scale_factor - 1
        else:
            center = scale_factor - 0.5
        for x in range(k):
            for y in range(k):
                bilinear_kernel[x, y] = (1 - abs(x - center) / scale_factor) * (1 - abs(y - center) / scale_factor)
        for i in range(ch):
            blob[i, 0, :, :] = bilinear_kernel
        return blob
def FillBilinear ( self , ch , k ) : blob = np . zeros ( shape = ( ch , 1 , k , k ) ) bilinear_kernel = np . zeros ( [ k , k ] , dtype = np . float32 ) scale_factor = ( k + 1 ) // 2 if k % 2 == 1 : center = scale_factor - 1 else : center = scale_factor - 0.5 for x in range ( k ) : for y in range ( k ) : bilinear_kernel [ x , y ] = ( 1 - abs ( x - center ) / scale_factor ) * ( 1 - abs ( y - center ) / scale_factor ) for i in range ( ch ) : blob [ i , 0 , : , : ] = bilinear_kernel return blob
Create bilinear weights in numpy array
Create bilinear weights in numpy array
""" Create bilinear weights in numpy array """
self
ch
k