def __init__(self, in_channels, out_channels, stride=1):
        super(ResBlock, self).__init__()
        self.in_channels = in_channels
        self.out_channels = out_channels
        self.conv1 = Conv2d(in_channels,
                            out_channels[0],
                            kernel_size=1,
                            bias=False)
        self.bn1 = BatchNorm2d(out_channels[0])
        self.relu = ReLU(True)

        self.conv2 = Conv2d(out_channels[0],
                            out_channels[0],
                            kernel_size=3,
                            padding=1,
                            stride=stride,
                            bias=False)
        self.bn2 = self.bn1

        self.conv3 = Conv2d(out_channels[0],
                            out_channels[1],
                            kernel_size=1,
                            bias=False)
        self.bn3 = BatchNorm2d(out_channels[1])

        if in_channels != out_channels:
            self.downsample = _make_downsample(in_channels, out_channels[1],
                                               stride)
        initialize_weights(self)
Ejemplo n.º 2
0
 def __init__(self, cfg, init_weights=True):
     super(CNN_2_Layer, self).__init__()
     self.cfg = cfg
     self.CNN = self._make_cnn()
     self.FCN = self._make_fcn()
     if init_weights:
         initialize_weights(self)
 def __init__(self, cfg):
     super(ResNet, self).__init__()
     self.cfg = cfg
     self.ResNet = _make_resnet(self)
     avg_in = int(cfg.MODEL.BACKBONE.INPUT_RESOLUTION *
                  cfg.MODEL.RESNET.POOLER_SCALE[-1])
     self.avgpool = AvgPool2d(avg_in, stride=1)
     initialize_weights(self)
Ejemplo n.º 4
0
 def __init__(self, config, init_weights=True):
     super(ImageClassifier, self).__init__()
     self.cfg = config
     self.back_bone = _make_back_bone(self.cfg)
     self.classifier = _make_classifier(self.cfg)
     if init_weights:
         initialize_weights(self)
     # 其他参数
     self.epoch = 0
 def __init__(self, cfg):
     super(BackBone, self).__init__()
     self.cfg = cfg
     # 搭建主干网
     if 'VGG' in self.cfg.MODEL.BACKBONE.NAME:
         self.features = _make_CNN(cfg)
     elif 'ResNet' in self.cfg.MODEL.BACKBONE.NAME:
         self.features = _make_resnet(cfg)
     initialize_weights(self)
Ejemplo n.º 6
0
 def __init__(self, cfg, init_weights=True):
     super(SingleLayer, self).__init__()
     self.cfg = cfg
     self.layer1 = Linear(784, 200)
     self.dropout = Dropout(0.5)
     self.layer2 = Linear(200, 10)
     self.ReLU = ReLU(inplace=True)
     if init_weights:
         initialize_weights(self)
Ejemplo n.º 7
0
 def __init__(self, cfg):
     super(FangClassification, self).__init__()
     self.cfg = cfg
     self.backbone = _make_back_bone(cfg)
     self.classifier = _make_classifier(cfg)
     initialize_weights(self)
Ejemplo n.º 8
0
 def __init__(self, cfg):
     super(Classifier, self).__init__()
     self.cfg = cfg
     self.drop = Dropout(0.5)
     self.FCN = _make_FCN(cfg)
     initialize_weights(self)