Ejemplo n.º 1
0
    def __init__(self, inplanes, planes, stride=1, downsample=None):
        super(IRBlock, self).__init__()
        self.conv1 = conv3x3(inplanes, planes, stride=stride)
        self.bn1 = bn_with_initialize(planes)
        self.relu1 = P.ReLU()
        self.conv2 = conv3x3(planes, planes, stride=1)
        self.bn2 = bn_with_initialize(planes)

        if downsample is None:
            self.downsample = Cut()
        else:
            self.downsample = downsample

        self.add = TensorAdd()
        self.cast = P.Cast()
        self.relu2 = P.ReLU()
Ejemplo n.º 2
0
 def __init__(self, inplanes, planes, expansion, stride):
     super(DownSample, self).__init__()
     self.conv1 = conv1x1(inplanes,
                          planes * expansion,
                          stride=stride,
                          pad_mode="valid")
     self.bn1 = bn_with_initialize(planes * expansion)
Ejemplo n.º 3
0
    def __init__(self, block, layers, flat_dim, fc_dim, attri_num_list):
        super(AttriResNet, self).__init__()

        # resnet18
        self.inplanes = 32
        self.conv1 = conv3x3(3, self.inplanes, stride=1)
        self.bn1 = bn_with_initialize(self.inplanes)
        self.relu = P.ReLU()
        self.layer1 = MakeLayer(block,
                                inplanes=32,
                                planes=64,
                                blocks=layers[0],
                                stride=2)
        self.layer2 = MakeLayer(block,
                                inplanes=64,
                                planes=128,
                                blocks=layers[1],
                                stride=2)
        self.layer3 = MakeLayer(block,
                                inplanes=128,
                                planes=256,
                                blocks=layers[2],
                                stride=2)
        self.layer4 = MakeLayer(block,
                                inplanes=256,
                                planes=512,
                                blocks=layers[3],
                                stride=2)

        # avg global pooling
        self.mean = P.ReduceMean(keep_dims=True)
        self.shape = P.Shape()
        self.reshape = P.Reshape()
        self.head = get_attri_head(flat_dim, fc_dim, attri_num_list)