本文整理匯總了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()