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


Python vgg.VGG16屬性代碼示例

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


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

示例1: __init__

# 需要導入模塊: import vgg [as 別名]
# 或者: from vgg import VGG16 [as 別名]
def __init__(self, n_classes):
        super(RUN300, self).__init__()
        self.n_classes = n_classes

        self.Base = VGG16()
        self.Extra = nn.Sequential(OrderedDict([
            ('extra1_1', nn.Conv2d(1024, 256, 1)),
            ('extra1_2', nn.Conv2d(256, 512, 3, padding=1, stride=2)),
            ('extra2_1', nn.Conv2d(512, 128, 1)),
            ('extra2_2', nn.Conv2d(128, 256, 3, padding=1, stride=2)),
            ('extra3_1', nn.Conv2d(256, 128, 1)),
            ('extra3_2', nn.Conv2d(128, 256, 3)),
            ('extra4_1', nn.Conv2d(256, 128, 1)),
            ('extra4_2', nn.Conv2d(128, 256, 3))]))
        self.pred_layers = ['conv4_3', 'conv7', 'extra1_2', 'extra2_2', 'extra3_2','extra4_2']
        n_channels = [512, 1024, 512, 256, 256, 256]

        self.L2Norm = nn.ModuleList([L2Norm(512, 20)])
        self.l2norm_layers = ['conv4_3']

        # Multi-Way Residual Blocks
        self.ResBlocks = nn.ModuleList()
        for i in range(len(n_channels) - 1):
            self.ResBlocks.append(
                ThreeWay(n_channels[i], n_channels[i+1], self.config['grids'][i], self.config['grids'][i+1], 
                         out_channels=256))
        self.ResBlocks.append(TwoWay(n_channels[-1], out_channels=256))

        # Unified Prediction Module
        n_boxes = len(self.config['aspect_ratios']) + 1
        #self.Loc  = nn.Conv2d(256, n_boxes * 4, 3, padding=1)
        #self.Conf = nn.Conv2d(256, n_boxes * (self.n_classes+1), 3, padding=1)
        self.Loc = nn.Sequential(
            nn.Conv2d(256, 256, 1),
            nn.ReLU(inplace=True),
            nn.Conv2d(256, n_boxes * 4, 3, padding=1))
        self.Conf = nn.Sequential(
            nn.Conv2d(256, 256, 1),
            nn.ReLU(inplace=True),
            nn.Conv2d(256, n_boxes * (self.n_classes+1), 3, padding=1)) 
開發者ID:uoip,項目名稱:SSD-variants,代碼行數:42,代碼來源:RUN.py

示例2: __init__

# 需要導入模塊: import vgg [as 別名]
# 或者: from vgg import VGG16 [as 別名]
def __init__(self, n_classes=1):
        super().__init__()

        self.n_classes = n_classes
        self.rolling_times = 4
        self.rolling_ratio = 0.075

        self.Base = VGG16()
        self.Extra = nn.Sequential(OrderedDict([
            ('extra1_1', nn.Conv2d(1024, 256, 1)),
            ('extra1_2', nn.Conv2d(256, 256, 3, padding=1, stride=2)),
            ('extra2_1', nn.Conv2d(256, 128, 1)),
            ('extra2_2', nn.Conv2d(128, 256, 3, padding=1, stride=2)),
            ('extra3_1', nn.Conv2d(256, 128, 1)),
            ('extra3_2', nn.Conv2d(128, 256, 3, padding=1, stride=2))]))
        self.pred_layers = ['conv4_3', 'conv7', 'extra1_2', 'extra2_2', 'extra3_2']

        self.L2Norm = nn.ModuleList([L2Norm(512, 20)])
        self.l2norm_layers = ['conv4_3']

        # intermediate layers
        self.Inter = nn.ModuleList([
            nn.Sequential(nn.Conv2d(512, 256, 3, padding=1), nn.ReLU(inplace=True))
            nn.Sequential(nn.Conv2d(1024, 256, 3, padding=1), nn.ReLU(inplace=True))
            nn.Sequential(),
            nn.Sequential(),
            nn.Sequential()])
        n_channels = [256, 256, 256, 256, 256]

        # Recurrent Rolling
        self.RollLeft = nn.ModuleList([])
        self.RollRight = nn.ModuleList([])
        self.Roll = nn.ModuleList([])
        for i in range(len(n_channels)):
            n_out = int(n_channels[i] * self.rolling_ratio)
            if i > 0:
                self.RollLeft.append( nn.Sequential(
                    nn.Conv2d(n_channels[i-1], n_out, 1), 
                    nn.ReLU(inplace=True), 
                    nn.MaxPool2d(2, ceil_mode=True)))
            if i < len(n_channels) - 1:
                self.RollRight.append( nn.Sequential(
                    nn.Conv2d(n_channels[i+1], n_out, 1), 
                    nn.Relu(inplace=True), 
                    nn.ConvTranspose2d(n_out, n_out, kernel_size=4, stride=2, padding=1)))

            n_out = n_out * (int(i>0) + int(i<len(n_channels)-1))
            self.Roll.append(nn.Sequential(
                    nn.Conv2d(n_channels[i] + n_out, n_channels[i], 1), 
                    nn.ReLU(inplace=True)))

        # Prediction
        self.Loc = nn.ModuleList([])
        self.Conf = nn.ModuleList([])
        for i in range(len(n_channels)):
            n_boxes = len(self.config['aspect_ratios'][i]) + 1
            self.Loc.append(nn.Conv2d(n_channels[i], n_boxes * 4, 3, padding=1))
            self.Conf.append(nn.Conv2d(n_channels[i], n_boxes * (self.n_classes + 1), 3, padding=1)) 
開發者ID:uoip,項目名稱:SSD-variants,代碼行數:60,代碼來源:RRC.py


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