當前位置: 首頁>>代碼示例>>Python>>正文


Python common.default_conv方法代碼示例

本文整理匯總了Python中model.common.default_conv方法的典型用法代碼示例。如果您正苦於以下問題:Python common.default_conv方法的具體用法?Python common.default_conv怎麽用?Python common.default_conv使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在model.common的用法示例。


在下文中一共展示了common.default_conv方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from model import common [as 別名]
# 或者: from model.common import default_conv [as 別名]
def __init__(self, args, conv=common.default_conv):
        super(VDSR, self).__init__()

        n_resblocks = args.n_resblocks
        n_feats = args.n_feats
        kernel_size = 3 
        self.url = url['r{}f{}'.format(n_resblocks, n_feats)]
        self.sub_mean = common.MeanShift(args.rgb_range)
        self.add_mean = common.MeanShift(args.rgb_range, sign=1)

        def basic_block(in_channels, out_channels, act):
            return common.BasicBlock(
                conv, in_channels, out_channels, kernel_size,
                bias=True, bn=False, act=act
            )

        # define body module
        m_body = []
        m_body.append(basic_block(args.n_colors, n_feats, nn.ReLU(True)))
        for _ in range(n_resblocks - 2):
            m_body.append(basic_block(n_feats, n_feats, nn.ReLU(True)))
        m_body.append(basic_block(n_feats, args.n_colors, None))

        self.body = nn.Sequential(*m_body) 
開發者ID:HolmesShuan,項目名稱:OISR-PyTorch,代碼行數:26,代碼來源:vdsr.py

示例2: __init__

# 需要導入模塊: from model import common [as 別名]
# 或者: from model.common import default_conv [as 別名]
def __init__(self, args, conv=common.default_conv):
        super(MDSR, self).__init__()
        n_resblocks = args.n_resblocks
        n_feats = args.n_feats
        kernel_size = 3
        act = nn.ReLU(True)
        self.scale_idx = 0
        self.url = url['r{}f{}'.format(n_resblocks, n_feats)]
        self.sub_mean = common.MeanShift(args.rgb_range)
        self.add_mean = common.MeanShift(args.rgb_range, sign=1)

        m_head = [conv(args.n_colors, n_feats, kernel_size)]

        self.pre_process = nn.ModuleList([
            nn.Sequential(
                common.ResBlock(conv, n_feats, 5, act=act),
                common.ResBlock(conv, n_feats, 5, act=act)
            ) for _ in args.scale
        ])

        m_body = [
            common.ResBlock(
                conv, n_feats, kernel_size, act=act
            ) for _ in range(n_resblocks)
        ]
        m_body.append(conv(n_feats, n_feats, kernel_size))

        self.upsample = nn.ModuleList([
            common.Upsampler(conv, s, n_feats, act=False) for s in args.scale
        ])

        m_tail = [conv(n_feats, args.n_colors, kernel_size)]

        self.head = nn.Sequential(*m_head)
        self.body = nn.Sequential(*m_body)
        self.tail = nn.Sequential(*m_tail) 
開發者ID:HolmesShuan,項目名稱:OISR-PyTorch,代碼行數:38,代碼來源:mdsr.py

示例3: __init__

# 需要導入模塊: from model import common [as 別名]
# 或者: from model.common import default_conv [as 別名]
def __init__(self, args, conv=common.default_conv):
        super(EDSR, self).__init__()

        n_resblocks = args.n_resblocks
        n_feats = args.n_feats
        kernel_size = 3 
        scale = args.scale[0]
        act = nn.ReLU(True)
        self.sub_mean = common.MeanShift(args.rgb_range)
        self.add_mean = common.MeanShift(args.rgb_range, sign=1)

        # define head module
        m_head = [conv(args.n_colors, n_feats, kernel_size)]

        # define body module
        m_body = [
            common.ResBlock(
                conv, n_feats, kernel_size, act=act, res_scale=args.res_scale
            ) for _ in range(n_resblocks)
        ]
        m_body.append(conv(n_feats, n_feats, kernel_size))

        # define tail module
        m_tail = [
            common.Upsampler(conv, scale, n_feats, act=False),
            conv(n_feats, args.n_colors, kernel_size)
        ]

        self.head = nn.Sequential(*m_head)
        self.body = nn.Sequential(*m_body)
        self.tail = nn.Sequential(*m_tail) 
開發者ID:HolmesShuan,項目名稱:OISR-PyTorch,代碼行數:33,代碼來源:edsr.py

示例4: __init__

# 需要導入模塊: from model import common [as 別名]
# 或者: from model.common import default_conv [as 別名]
def __init__(self, args, conv=common.default_conv):
        super(RCAN, self).__init__()
        
        n_resgroups = args.n_resgroups
        n_resblocks = args.n_resblocks
        n_feats = args.n_feats
        kernel_size = 3
        reduction = args.reduction 
        scale = args.scale[0]
        act = nn.ReLU(True)
        
        # RGB mean for DIV2K
        self.sub_mean = common.MeanShift(args.rgb_range)
        
        # define head module
        modules_head = [conv(args.n_colors, n_feats, kernel_size)]

        # define body module
        modules_body = [
            ResidualGroup(
                conv, n_feats, kernel_size, reduction, act=act, res_scale=args.res_scale, n_resblocks=n_resblocks) \
            for _ in range(n_resgroups)]

        modules_body.append(conv(n_feats, n_feats, kernel_size))

        # define tail module
        modules_tail = [
            common.Upsampler(conv, scale, n_feats, act=False),
            conv(n_feats, args.n_colors, kernel_size)]

        self.add_mean = common.MeanShift(args.rgb_range, sign=1)

        self.head = nn.Sequential(*modules_head)
        self.body = nn.Sequential(*modules_body)
        self.tail = nn.Sequential(*modules_tail) 
開發者ID:HolmesShuan,項目名稱:OISR-PyTorch,代碼行數:37,代碼來源:rcan.py

示例5: __init__

# 需要導入模塊: from model import common [as 別名]
# 或者: from model.common import default_conv [as 別名]
def __init__(self, args, conv=common.default_conv):
        super(EDSR, self).__init__()

        n_resblocks = args.n_resblocks
        n_feats = args.n_feats
        kernel_size = 3 
        scale = args.scale[0]
        act = nn.ReLU(True)
        # self.url = url['r{}f{}x{}'.format(n_resblocks, n_feats, scale)]
        self.sub_mean = common.MeanShift(args.rgb_range)
        self.add_mean = common.MeanShift(args.rgb_range, sign=1)

        # define head module
        m_head = [conv(args.n_colors, n_feats, kernel_size)]

        # define body module
        m_body = [
            common.ResBlock(
                conv, n_feats, kernel_size, act=act, res_scale=args.res_scale
            ) for _ in range(n_resblocks)
        ]
        m_body.append(conv(n_feats, n_feats, kernel_size))

        # define tail module
        m_tail = [
            common.Upsampler(conv, scale, n_feats, act=False),
            conv(n_feats, args.n_colors, kernel_size)
        ]

        self.head = nn.Sequential(*m_head)
        self.body = nn.Sequential(*m_body)
        self.tail = nn.Sequential(*m_tail) 
開發者ID:HolmesShuan,項目名稱:OISR-PyTorch,代碼行數:34,代碼來源:edsr.py

示例6: __init__

# 需要導入模塊: from model import common [as 別名]
# 或者: from model.common import default_conv [as 別名]
def __init__(self, n_resblock=24, n_feats=256, scale=2, bias=True, norm_type=False,
                 act_type='prelu'):
        super(NET, self).__init__()

        self.scale = scale
        m = [common.default_conv(1, n_feats, 3, stride=2)]
        m += [nn.PixelShuffle(2),
              common.ConvBlock(n_feats//4, n_feats, bias=True, act_type=act_type)
              ]

        m += [common.ResBlock(n_feats, 3, norm_type, act_type, res_scale=1, bias=bias)
                             for _ in range(n_resblock)]

        for _ in range(int(math.log(scale, 2))):
            m += [nn.PixelShuffle(2),
                  common.ConvBlock(n_feats//4, n_feats, bias=True, act_type=act_type)
                  ]

        m += [common.default_conv(n_feats, 3, 3)]

        self.model = nn.Sequential(*m)
        for m in self.modules():
            # pdb.set_trace()
            if isinstance(m, nn.Conv2d):
                # Xavier
                # nn.init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='relu')
                nn.init.xavier_normal_(m.weight)
                m.weight.requires_grad = True
                if m.bias is not None:
                    m.bias.data.zero_()
                    m.bias.requires_grad = True 
開發者ID:guochengqian,項目名稱:TENet,代碼行數:33,代碼來源:ruofan.py

示例7: __init__

# 需要導入模塊: from model import common [as 別名]
# 或者: from model.common import default_conv [as 別名]
def __init__(self, args, conv=common.default_conv):
        super(EDSR, self).__init__()

        n_resblocks = args.n_resblocks
        n_feats = args.n_feats
        kernel_size = 3 
        scale = args.scale[0]
        act = nn.ReLU(True)
        url_name = 'r{}f{}x{}'.format(n_resblocks, n_feats, scale)
        if url_name in url:
            self.url = url[url_name]
        else:
            self.url = None
        self.sub_mean = common.MeanShift(args.rgb_range)
        self.add_mean = common.MeanShift(args.rgb_range, sign=1)

        # define head module
        m_head = [conv(args.n_colors, n_feats, kernel_size)]

        # define body module
        m_body = [
            common.ResBlock(
                conv, n_feats, kernel_size, act=act, res_scale=args.res_scale
            ) for _ in range(n_resblocks)
        ]
        m_body.append(conv(n_feats, n_feats, kernel_size))

        # define tail module
        m_tail = [
            common.Upsampler(conv, scale, n_feats, act=False),
            conv(n_feats, args.n_colors, kernel_size)
        ]

        self.head = nn.Sequential(*m_head)
        self.body = nn.Sequential(*m_body)
        self.tail = nn.Sequential(*m_tail) 
開發者ID:thstkdgus35,項目名稱:EDSR-PyTorch,代碼行數:38,代碼來源:edsr.py

示例8: __init__

# 需要導入模塊: from model import common [as 別名]
# 或者: from model.common import default_conv [as 別名]
def __init__(self, args, conv=common.default_conv):
        super(NHR_Res32, self).__init__()
        n_resblocks = args.n_resblocks
        args.n_resblocks = args.n_resblocks - args.n_resblocks_ft
        n_feats = args.n_feats
        kernel_size = 3
        scale = args.scale[0]
        act = nn.ReLU(True)

        tail_ft2 = [
            common.ResBlock(
                conv, n_feats+4, kernel_size, act=act, res_scale=args.res_scale
            ) for _ in range(args.n_resblocks_ft)
        ]
        tail_ft2.append(conv(n_feats+4, args.n_colors, kernel_size))

        tail_ft1 = [
            common.Upsampler(conv, scale, n_feats, act=False),
        ]
        premodel = EDSR(args)
        self.sub_mean = premodel.sub_mean
        self.head = premodel.head
        body = premodel.body
        body_child = list(body.children())
        body_ft = [body_child.pop()]
        self.body = nn.Sequential(*body_child)
        self.body_ft = nn.Sequential(*body_ft)
        self.tail_ft1 = nn.Sequential(*tail_ft1)
        self.tail_ft2 = nn.Sequential(*tail_ft2)
        self.add_mean = premodel.add_mean
        args.n_resblocks = n_resblocks
        # self.premodel = EDSR(args)
        # from IPython import embed; embed(); exit() 
開發者ID:ofsoundof,項目名稱:3D_Appearance_SR,代碼行數:35,代碼來源:finetune.py

示例9: __init__

# 需要導入模塊: from model import common [as 別名]
# 或者: from model.common import default_conv [as 別名]
def __init__(self, conv=common.default_conv, n_feats=64, kernel_size=3, reg_act=nn.Softplus(), rescale=1, norm_f=None):
        super(VarBlockSimple, self).__init__()
        if norm_f is not None:
            conv_mask = [norm_f, nn.Conv2d(n_feats, n_feats, kernel_size=kernel_size, padding=kernel_size//2, groups=n_feats), reg_act]
        else:
            conv_mask = [nn.Conv2d(n_feats, n_feats, kernel_size=kernel_size, padding=kernel_size//2, groups=n_feats), reg_act]
        conv_body = [conv(n_feats, n_feats, kernel_size), nn.PReLU()]
        self.rescale = rescale
        self.conv_mask = nn.Sequential(*conv_mask)
        self.conv_body = nn.Sequential(*conv_body) 
開發者ID:ofsoundof,項目名稱:3D_Appearance_SR,代碼行數:12,代碼來源:srresnet.py


注:本文中的model.common.default_conv方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。