本文整理汇总了Python中utils.net.get_group_gn方法的典型用法代码示例。如果您正苦于以下问题:Python net.get_group_gn方法的具体用法?Python net.get_group_gn怎么用?Python net.get_group_gn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.net
的用法示例。
在下文中一共展示了net.get_group_gn方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from utils import net [as 别名]
# 或者: from utils.net import get_group_gn [as 别名]
def __init__(self, dim_in, roi_xform_func, spatial_scale):
super().__init__()
self.dim_in = dim_in
self.roi_xform = roi_xform_func
self.spatial_scale = spatial_scale
hidden_dim = cfg.FAST_RCNN.CONV_HEAD_DIM
module_list = []
for i in range(cfg.FAST_RCNN.NUM_STACKED_CONVS):
module_list.extend([
nn.Conv2d(dim_in, hidden_dim, 3, 1, 1, bias=False),
nn.GroupNorm(net_utils.get_group_gn(hidden_dim), hidden_dim,
eps=cfg.GROUP_NORM.EPSILON),
nn.ReLU(inplace=True)
])
dim_in = hidden_dim
self.convs = nn.Sequential(*module_list)
self.dim_out = fc_dim = cfg.FAST_RCNN.MLP_HEAD_DIM
roi_size = cfg.FAST_RCNN.ROI_XFORM_RESOLUTION
self.fc = nn.Linear(dim_in * roi_size * roi_size, fc_dim)
self._init_weights()
示例2: __init__
# 需要导入模块: from utils import net [as 别名]
# 或者: from utils.net import get_group_gn [as 别名]
def __init__(self, dim_in, roi_xform_func, spatial_scale, num_convs):
super().__init__()
self.dim_in = dim_in
self.roi_xform = roi_xform_func
self.spatial_scale = spatial_scale
self.num_convs = num_convs
dilation = cfg.MRCNN.DILATION
dim_inner = cfg.MRCNN.DIM_REDUCED
self.dim_out = dim_inner
module_list = []
for i in range(num_convs):
module_list.extend([
nn.Conv2d(dim_in, dim_inner, 3, 1, padding=1*dilation, dilation=dilation, bias=False),
nn.GroupNorm(net_utils.get_group_gn(dim_inner), dim_inner, eps=cfg.GROUP_NORM.EPSILON),
nn.ReLU(inplace=True)
])
dim_in = dim_inner
self.conv_fcn = nn.Sequential(*module_list)
# upsample layer
self.upconv = nn.ConvTranspose2d(dim_inner, dim_inner, 2, 2, 0)
self.apply(self._init_weights)
示例3: basic_gn_shortcut
# 需要导入模块: from utils import net [as 别名]
# 或者: from utils.net import get_group_gn [as 别名]
def basic_gn_shortcut(model, prefix, blob_in, dim_in, dim_out, stride):
if dim_in == dim_out:
return blob_in
# output name is prefix + '_branch1_gn'
return model.ConvGN(
blob_in,
prefix + '_branch1',
dim_in,
dim_out,
kernel=1,
group_gn=get_group_gn(dim_out),
stride=stride,
pad=0,
group=1,
)
# ------------------------------------------------------------------------------
# various stems (may expand and may consider a new helper)
# ------------------------------------------------------------------------------
示例4: __init__
# 需要导入模块: from utils import net [as 别名]
# 或者: from utils.net import get_group_gn [as 别名]
def __init__(self, dim_in_top, dim_in_lateral):
super().__init__()
self.dim_in_top = dim_in_top
self.dim_in_lateral = dim_in_lateral
self.dim_out = dim_in_top
if cfg.FPN.USE_GN:
self.conv_lateral = nn.Sequential(
nn.Conv2d(dim_in_lateral, self.dim_out, 1, 1, 0, bias=False),
nn.GroupNorm(net_utils.get_group_gn(self.dim_out), self.dim_out,
eps=cfg.GROUP_NORM.EPSILON)
)
else:
self.conv_lateral = nn.Conv2d(dim_in_lateral, self.dim_out, 1, 1, 0)
self._init_weights()
示例5: basic_gn_shortcut
# 需要导入模块: from utils import net [as 别名]
# 或者: from utils.net import get_group_gn [as 别名]
def basic_gn_shortcut(inplanes, outplanes, stride):
return nn.Sequential(
nn.Conv2d(inplanes,
outplanes,
kernel_size=1,
stride=stride,
bias=False),
nn.GroupNorm(net_utils.get_group_gn(outplanes), outplanes,
eps=cfg.GROUP_NORM.EPSILON)
)
# ------------------------------------------------------------------------------
# various stems (may expand and may consider a new helper)
# ------------------------------------------------------------------------------
示例6: basic_gn_stem
# 需要导入模块: from utils import net [as 别名]
# 或者: from utils.net import get_group_gn [as 别名]
def basic_gn_stem():
return nn.Sequential(OrderedDict([
('conv1', nn.Conv2d(3, 64, 7, stride=2, padding=3, bias=False)),
('gn1', nn.GroupNorm(net_utils.get_group_gn(64), 64,
eps=cfg.GROUP_NORM.EPSILON)),
('relu', nn.ReLU(inplace=True)),
('maxpool', nn.MaxPool2d(kernel_size=3, stride=2, padding=1))]))
# ------------------------------------------------------------------------------
# various transformations (may expand and may consider a new helper)
# ------------------------------------------------------------------------------
示例7: __init__
# 需要导入模块: from utils import net [as 别名]
# 或者: from utils.net import get_group_gn [as 别名]
def __init__(self, inplanes, outplanes, innerplanes, stride=1, dilation=1, group=1,
downsample=None):
super().__init__()
# In original resnet, stride=2 is on 1x1.
# In fb.torch resnet, stride=2 is on 3x3.
(str1x1, str3x3) = (stride, 1) if cfg.RESNETS.STRIDE_1X1 else (1, stride)
self.stride = stride
self.conv1 = nn.Conv2d(
inplanes, innerplanes, kernel_size=1, stride=str1x1, bias=False)
self.gn1 = nn.GroupNorm(net_utils.get_group_gn(innerplanes), innerplanes,
eps=cfg.GROUP_NORM.EPSILON)
self.conv2 = nn.Conv2d(
innerplanes, innerplanes, kernel_size=3, stride=str3x3, bias=False,
padding=1 * dilation, dilation=dilation, groups=group)
self.gn2 = nn.GroupNorm(net_utils.get_group_gn(innerplanes), innerplanes,
eps=cfg.GROUP_NORM.EPSILON)
self.conv3 = nn.Conv2d(
innerplanes, outplanes, kernel_size=1, stride=1, bias=False)
self.gn3 = nn.GroupNorm(net_utils.get_group_gn(outplanes), outplanes,
eps=cfg.GROUP_NORM.EPSILON)
self.downsample = downsample
self.relu = nn.ReLU(inplace=True)