自动扩充的应用

  • 目标
    Get the all index on the featuremap when the conv sliding on the featuremap
  1. Get the coordinates of conv(e.g., 3x3) and featuremap(e.g., 5x5)

    • c_x_y: relative coordinates(1,18) of conv
    • p_x_y: coordinates(1, 18, 5, 5) of featuremap
    # c_x_y: relative coordinates of conv
    # p_x_y:
    kernel_size = 3
    r = kernel_size // 2
    c_x, c_y = torch.meshgrid(torch.linspace(-r, r, 2*r+1)
                           torch.linspace(-r, r, 2*r+1))
    c_x_y = torch.cat((x,reshape(-1,1), y.reshape(-1,1)),dim=1)
    
    h=5
    w=5
    p_x, p_y = torch.meshgrid(torch.linspace(1, h, h),
                              torch.linspace(1, w, w))
    p_x = p_x.expand(1, kernel_size * kernel_size, h, w)
    p_y = p_y.expand(1, kernel_size * kernel_size, h, w)
    p_x_y = torch.cat((p_x, p_y), dim=1)
    

    mershgrid

  2. combine conv and featuremap

    • p: it's shape is same as p_x_y
    • p(x,y), x\in[0,w+1],y\in[0,h+1]
    p = c_x_y.reshape(1, 2*kernel_size*kernel_size, 1, 1) 
     +
        p_x_y
    
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容