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


Python resnet.conv3x3方法代码示例

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


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

示例1: __init__

# 需要导入模块: from torchvision.models import resnet [as 别名]
# 或者: from torchvision.models.resnet import conv3x3 [as 别名]
def __init__(self, in_planes, out_planes, nb_compressions=0, norm_layer=None):

        if norm_layer is None:
            norm_layer = nn.BatchNorm2d

        layers = [conv3x3(in_planes, out_planes),
                  norm_layer(out_planes),
                  nn.LeakyReLU(0.1, inplace=True)]
        for _ in range(nb_compressions):
            layers.extend([conv1x1(out_planes, in_planes),
                           norm_layer(in_planes),
                           nn.LeakyReLU(0.1, inplace=True),
                           conv3x3(in_planes, out_planes),
                           norm_layer(out_planes),
                           nn.LeakyReLU(0.1, inplace=True)])

        super().__init__(*layers) 
开发者ID:frgfm,项目名称:Holocron,代码行数:19,代码来源:darknet.py

示例2: __init__

# 需要导入模块: from torchvision.models import resnet [as 别名]
# 或者: from torchvision.models.resnet import conv3x3 [as 别名]
def __init__(self, config_channels, prefix, channels, stride=1):
        nn.Module.__init__(self)
        channels_in = config_channels.channels
        self.conv1 = conv3x3(config_channels.channels, config_channels(channels, '%s.conv1.weight' % prefix), stride)
        self.bn1 = nn.BatchNorm2d(config_channels.channels)
        self.relu = nn.ReLU(inplace=True)
        self.conv2 = conv3x3(config_channels.channels, config_channels(channels, '%s.conv2.weight' % prefix))
        self.bn2 = nn.BatchNorm2d(config_channels.channels)
        if stride > 1 or channels_in != config_channels.channels:
            downsample = []
            downsample.append(nn.Conv2d(channels_in, config_channels.channels, kernel_size=1, stride=stride, bias=False))
            downsample.append(nn.BatchNorm2d(config_channels.channels))
            self.downsample = nn.Sequential(*downsample)
        else:
            self.downsample = None 
开发者ID:ruiminshen,项目名称:yolo2-pytorch,代码行数:17,代码来源:resnet.py

示例3: __init__

# 需要导入模块: from torchvision.models import resnet [as 别名]
# 或者: from torchvision.models.resnet import conv3x3 [as 别名]
def __init__(self, inplanes, planes, stride=1, downsample=None, groups=1,
                 base_width=4, dilation=1, scale=4, first_block=False, norm_layer=None):
        """Implements a residual block
        Args:
            inplanes (int): input channel dimensionality
            planes (int): output channel dimensionality
            stride (int): stride used for conv3x3
            downsample (torch.nn.Module): module used for downsampling
            groups: num of convolution groups
            base_width: base width
            dilation (int): dilation rate of conv3x3
            scale (int): scaling ratio for cascade convs
            first_block (bool): whether the block is the first to be placed in the conv layer
            norm_layer (torch.nn.Module): norm layer to be used in blocks
        """
        super(Res2Block, self).__init__()
        if norm_layer is None:
            norm_layer = nn.BatchNorm2d

        width = int(planes * (base_width / 64.)) * groups

        self.conv1 = conv1x1(inplanes, width * scale)
        self.bn1 = norm_layer(width * scale)

        # If scale == 1, single conv else identity & (scale - 1) convs
        nb_branches = max(scale, 2) - 1
        if first_block:
            self.pool = nn.AvgPool2d(kernel_size=3, stride=stride, padding=1)
        self.convs = nn.ModuleList([conv3x3(width, width, stride, groups, dilation)
                                    for _ in range(nb_branches)])
        self.bns = nn.ModuleList([norm_layer(width) for _ in range(nb_branches)])
        self.first_block = first_block
        self.scale = scale

        self.conv3 = conv1x1(width * scale, planes * self.expansion)
        self.bn3 = norm_layer(planes * self.expansion)
        self.relu = nn.ReLU(inplace=False)

        self.downsample = downsample 
开发者ID:frgfm,项目名称:Holocron,代码行数:41,代码来源:res2net.py

示例4: __init__

# 需要导入模块: from torchvision.models import resnet [as 别名]
# 或者: from torchvision.models.resnet import conv3x3 [as 别名]
def __init__(self, inplanes, planes, stride=1, downsample=None, groups=1,
                 base_width=4, dilation=1, scale=4, first_block=False, norm_layer=None):
        """Implements a residual block
        Args:
            inplanes (int): input channel dimensionality
            planes (int): output channel dimensionality
            stride (int): stride used for conv3x3
            downsample (torch.nn.Module): module used for downsampling
            groups: num of convolution groups
            base_width: base width
            dilation (int): dilation rate of conv3x3            
            scale (int): scaling ratio for cascade convs
            first_block (bool): whether the block is the first to be placed in the conv layer
            norm_layer (torch.nn.Module): norm layer to be used in blocks
        """
        super(Res2Block, self).__init__()
        if norm_layer is None:
            norm_layer = nn.BatchNorm2d

        width = int(planes * (base_width / 64.)) * groups

        self.conv1 = conv1x1(inplanes, width * scale)
        self.bn1 = norm_layer(width * scale)

        # If scale == 1, single conv else identity & (scale - 1) convs
        nb_branches = max(scale, 2) - 1
        if first_block:
            self.pool = nn.AvgPool2d(kernel_size=3, stride=stride, padding=1)
        self.convs = nn.ModuleList([conv3x3(width, width, stride, groups, dilation)
                                    for _ in range(nb_branches)])
        self.bns = nn.ModuleList([norm_layer(width) for _ in range(nb_branches)])
        self.first_block = first_block
        self.scale = scale

        self.conv3 = conv1x1(width * scale, planes * self.expansion)
        
        self.relu = Mish() #nn.ReLU(inplace=False)
        self.bn3 = norm_layer(planes * self.expansion)  #bn reverse

        self.downsample = downsample 
开发者ID:lessw2020,项目名称:res2net-plus,代码行数:42,代码来源:res2fg.py

示例5: __init__

# 需要导入模块: from torchvision.models import resnet [as 别名]
# 或者: from torchvision.models.resnet import conv3x3 [as 别名]
def __init__(self, inplanes, planes, stride=1, downsample=None):
        super(BasicBlockV2, self).__init__()
        self.relu = nn.ReLU(inplace=True)

        self.bn1 = nn.BatchNorm2d(inplanes)
        self.conv1 = conv3x3(inplanes, planes, stride=stride)
        self.bn2 = nn.BatchNorm2d(planes)
        self.conv2 = conv3x3(planes, planes, stride=1)

        self.downsample = downsample
        self.stride = stride 
开发者ID:nyukat,项目名称:GMIC,代码行数:13,代码来源:modules.py


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