PSPnet模型结构及实现代码
该模块融合了4种不同金字塔尺度的特征,第一行红色是最粗糙的特征–全局池化生成单个bin输出,后面三行是不同尺度的池化特征。 为了保证全局特征的权重,如果金字塔共有N个级别,则在每个级别后使用1×1 1×11×1的卷积将对于级别通道降为原本的1/N。再通过双线性插值获得未池化前的大小,最终concat到一起。 1 import torch 2 import torch.nn.functional as F 3 from torch import nn 4 from torchvision import models 5 6 from utils import initialize_weights 7 from utils.misc import Conv2dDeformable 8 from .config import res101_path 9 10 //金字塔模块,将从前面卷积结构提取的特征分别进行不同的池化操作,得到不同感受野以及全局语境信息(或者叫做不同层级的信息) 11 class _PyramidPoolingModule(nn.Module): 12 def __init__ (self, in_dim, reduction_dim, setting): 13 super(_PyramidPoolingModule, self). __init__ () 14