本文整理匯總了Python中maskrcnn_benchmark.layers.ConvTranspose2d方法的典型用法代碼示例。如果您正苦於以下問題:Python layers.ConvTranspose2d方法的具體用法?Python layers.ConvTranspose2d怎麽用?Python layers.ConvTranspose2d使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類maskrcnn_benchmark.layers
的用法示例。
在下文中一共展示了layers.ConvTranspose2d方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from maskrcnn_benchmark import layers [as 別名]
# 或者: from maskrcnn_benchmark.layers import ConvTranspose2d [as 別名]
def __init__(self, cfg, in_channels):
super(KeypointRCNNPredictor, self).__init__()
input_features = in_channels
num_keypoints = cfg.MODEL.ROI_KEYPOINT_HEAD.NUM_CLASSES
deconv_kernel = 4
self.kps_score_lowres = layers.ConvTranspose2d(
input_features,
num_keypoints,
deconv_kernel,
stride=2,
padding=deconv_kernel // 2 - 1,
)
nn.init.kaiming_normal_(
self.kps_score_lowres.weight, mode="fan_out", nonlinearity="relu"
)
nn.init.constant_(self.kps_score_lowres.bias, 0)
self.up_scale = 2
self.out_channels = num_keypoints
示例2: __init__
# 需要導入模塊: from maskrcnn_benchmark import layers [as 別名]
# 或者: from maskrcnn_benchmark.layers import ConvTranspose2d [as 別名]
def __init__(self, cfg, in_channels):
super(MaskRCNNC4Predictor, self).__init__()
num_classes = cfg.MODEL.ROI_BOX_HEAD.NUM_CLASSES
dim_reduced = cfg.MODEL.ROI_MASK_HEAD.CONV_LAYERS[-1]
num_inputs = in_channels
self.conv5_mask = ConvTranspose2d(num_inputs, dim_reduced, 2, 2, 0)
self.mask_fcn_logits = Conv2d(dim_reduced, num_classes, 1, 1, 0)
for name, param in self.named_parameters():
if "bias" in name:
nn.init.constant_(param, 0)
elif "weight" in name:
# Caffe2 implementation uses MSRAFill, which in fact
# corresponds to kaiming_normal_ in PyTorch
nn.init.kaiming_normal_(param, mode="fan_out", nonlinearity="relu")
示例3: __init__
# 需要導入模塊: from maskrcnn_benchmark import layers [as 別名]
# 或者: from maskrcnn_benchmark.layers import ConvTranspose2d [as 別名]
def __init__(self, cfg):
super(MaskRCNNC4Predictor, self).__init__()
num_classes = cfg.MODEL.ROI_BOX_HEAD.NUM_CLASSES
dim_reduced = cfg.MODEL.ROI_MASK_HEAD.CONV_LAYERS[-1]
if cfg.MODEL.ROI_HEADS.USE_FPN:
num_inputs = dim_reduced
else:
stage_index = 4
stage2_relative_factor = 2 ** (stage_index - 1)
res2_out_channels = cfg.MODEL.RESNETS.RES2_OUT_CHANNELS
num_inputs = res2_out_channels * stage2_relative_factor
self.conv5_mask = ConvTranspose2d(num_inputs, dim_reduced, 2, 2, 0)
self.mask_fcn_logits = Conv2d(dim_reduced, num_classes, 1, 1, 0)
for name, param in self.named_parameters():
if "bias" in name:
nn.init.constant_(param, 0)
elif "weight" in name:
# Caffe2 implementation uses MSRAFill, which in fact
# corresponds to kaiming_normal_ in PyTorch
nn.init.kaiming_normal_(param, mode="fan_out", nonlinearity="relu")
示例4: __init__
# 需要導入模塊: from maskrcnn_benchmark import layers [as 別名]
# 或者: from maskrcnn_benchmark.layers import ConvTranspose2d [as 別名]
def __init__(self, cfg):
super(KeypointRCNNPredictor, self).__init__()
input_features = cfg.MODEL.ROI_KEYPOINT_HEAD.CONV_LAYERS[-1]
num_keypoints = cfg.MODEL.ROI_KEYPOINT_HEAD.NUM_CLASSES
deconv_kernel = 4
self.kps_score_lowres = layers.ConvTranspose2d(
input_features,
num_keypoints,
deconv_kernel,
stride=2,
padding=deconv_kernel // 2 - 1,
)
nn.init.kaiming_normal_(
self.kps_score_lowres.weight, mode="fan_out", nonlinearity="relu"
)
nn.init.constant_(self.kps_score_lowres.bias, 0)
self.up_scale = 2
示例5: __init__
# 需要導入模塊: from maskrcnn_benchmark import layers [as 別名]
# 或者: from maskrcnn_benchmark.layers import ConvTranspose2d [as 別名]
def __init__(self, num_inputs=256, dim_reduced=256, num_conv=0, no_transform1=False, first_kernel=3,
no_relu=False, use_leaky_relu=False):
super(DeConvUpSampler, self).__init__()
self.first_kernel = first_kernel
self.no_relu = no_relu
self.use_leaky_relu = use_leaky_relu
if no_transform1:
self.transform1 = EmptyBlock()
else:
self.transform1 = self.build_transform(num_inputs, dim_reduced, dim_reduced, num_conv)
self.deconv1 = ConvTranspose2d(dim_reduced, dim_reduced, 2, 2, 0)
self.transform2 = self.build_transform(dim_reduced, dim_reduced, dim_reduced, num_conv)
self.deconv2 = ConvTranspose2d(dim_reduced, num_inputs, 2, 2, 0)
for modules in [self.transform1.modules(), self.transform2.modules(), [self.deconv1, self.deconv2]]:
for l in modules:
if isinstance(l, (nn.Conv2d, nn.ConvTranspose2d)):
nn.init.kaiming_normal_(l.weight, mode="fan_out", nonlinearity="relu")
nn.init.constant_(l.bias, 0)