当前位置: 首页>>代码示例>>Python>>正文


Python functional.upsample_nearest方法代码示例

本文整理汇总了Python中torch.nn.functional.upsample_nearest方法的典型用法代码示例。如果您正苦于以下问题:Python functional.upsample_nearest方法的具体用法?Python functional.upsample_nearest怎么用?Python functional.upsample_nearest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在torch.nn.functional的用法示例。


在下文中一共展示了functional.upsample_nearest方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _dropout

# 需要导入模块: from torch.nn import functional [as 别名]
# 或者: from torch.nn.functional import upsample_nearest [as 别名]
def _dropout(self, x, masks):
        # x: n x c x h x w
        # masks: n x 1 x 4 x 4
        # sample_num = x.data.size(0)
        height = x.data.size(2)
        width = x.data.size(3)
        assert(height == width)
        scale = height / 4
        # print(scale)
        # assert (len(ys) == len(xs))
        # masks = masks.unsqueeze(1)
        # print(masks.size())
        # masks = 1 - masks
        # print(masks[0])
        if scale != 1:
            masks = F.upsample_nearest(masks, scale_factor=scale)
        # print(masks[0])
        # print(x[0, 1])
        x = x * masks.expand(x.size())
        # print(x[0, 1])
        # exit()
        return x 
开发者ID:zhiqiangdon,项目名称:pose-adv-aug,代码行数:24,代码来源:asn_stacked_hg.py

示例2: forward

# 需要导入模块: from torch.nn import functional [as 别名]
# 或者: from torch.nn.functional import upsample_nearest [as 别名]
def forward(self, x):
        from torch.nn import functional as F
        return F.upsample_nearest(x, scale_factor=2) 
开发者ID:nerox8664,项目名称:pytorch2keras,代码行数:5,代码来源:upsampling_nearest.py

示例3: scale_tensor

# 需要导入模块: from torch.nn import functional [as 别名]
# 或者: from torch.nn.functional import upsample_nearest [as 别名]
def scale_tensor(input,size=512,mode='bilinear'):
    print(input.size())
    # b,h,w = input.size()
    _, _, h, w = input.size()
    if mode == 'nearest':
        if h == 512 and w == 512:
            return input
        return F.upsample_nearest(input,size=(size,size))
    if h>512 and w > 512:
        return F.upsample(input, size=(size,size), mode=mode, align_corners=True)
    return F.upsample(input, size=(size,size), mode=mode, align_corners=True) 
开发者ID:Gaoyiminggithub,项目名称:Graphonomy,代码行数:13,代码来源:util.py


注:本文中的torch.nn.functional.upsample_nearest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。