本文整理汇总了Python中nn.BilinearInterpolation2d方法的典型用法代码示例。如果您正苦于以下问题:Python nn.BilinearInterpolation2d方法的具体用法?Python nn.BilinearInterpolation2d怎么用?Python nn.BilinearInterpolation2d使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nn
的用法示例。
在下文中一共展示了nn.BilinearInterpolation2d方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import nn [as 别名]
# 或者: from nn import BilinearInterpolation2d [as 别名]
def __init__(self, dim_in):
super().__init__()
self.upsample_heatmap = (cfg.KRCNN.UP_SCALE > 1)
if cfg.KRCNN.USE_DECONV:
# Apply ConvTranspose to the feature representation; results in 2x # upsampling
self.deconv = nn.ConvTranspose2d(
dim_in, cfg.KRCNN.DECONV_DIM, cfg.KRCNN.DECONV_KERNEL,
2, padding=int(cfg.KRCNN.DECONV_KERNEL / 2) - 1)
dim_in = cfg.KRCNN.DECONV_DIM
if cfg.KRCNN.USE_DECONV_OUTPUT:
# Use ConvTranspose to predict heatmaps; results in 2x upsampling
self.classify = nn.ConvTranspose2d(
dim_in, cfg.KRCNN.NUM_KEYPOINTS, cfg.KRCNN.DECONV_KERNEL,
2, padding=int(cfg.KRCNN.DECONV_KERNEL / 2 - 1))
else:
# Use Conv to predict heatmaps; does no upsampling
self.classify = nn.Conv2d(dim_in, cfg.KRCNN.NUM_KEYPOINTS, 1, 1, padding=0)
if self.upsample_heatmap:
# self.upsample = nn.UpsamplingBilinear2d(scale_factor=cfg.KRCNN.UP_SCALE)
self.upsample = mynn.BilinearInterpolation2d(
cfg.KRCNN.NUM_KEYPOINTS, cfg.KRCNN.NUM_KEYPOINTS, cfg.KRCNN.UP_SCALE)
self._init_weights()
示例2: __init__
# 需要导入模块: import nn [as 别名]
# 或者: from nn import BilinearInterpolation2d [as 别名]
def __init__(self, dim_in):
super().__init__()
self.dim_in = dim_in
n_classes = cfg.MODEL.NUM_CLASSES if cfg.MRCNN.CLS_SPECIFIC_MASK else 1
if cfg.MRCNN.USE_FC_OUTPUT:
# Predict masks with a fully connected layer
self.classify = nn.Linear(dim_in, n_classes * cfg.MRCNN.RESOLUTION**2)
else:
# Predict mask using Conv
self.classify = nn.Conv2d(dim_in, n_classes, 1, 1, 0)
if cfg.MRCNN.UPSAMPLE_RATIO > 1:
self.upsample = mynn.BilinearInterpolation2d(
n_classes, n_classes, cfg.MRCNN.UPSAMPLE_RATIO)
self._init_weights()