def __init__(self): super(ModelConv, self).__init__() with supernet(kernel_size=(3, 5, 7), channel=((4, 8, 12), (8, 12, 16), (8, 12, 16), (8, 12, 16))) as ofa_super: models = [] models += [nn.Conv2D(3, 4, 3, padding=1)] models += [nn.InstanceNorm(4)] models += [ReLU()] models += [nn.Conv2D(4, 4, 3, groups=4)] models += [nn.InstanceNorm(4)] models += [ReLU()] models += [ nn.Conv2DTranspose(4, 4, 3, groups=4, padding=1, use_cudnn=True) ] models += [nn.BatchNorm(4)] models += [ReLU()] models += [nn.Conv2D(4, 3, 3)] models += [ReLU()] models = ofa_super.convert(models) models += [ Block(SuperSeparableConv2D(3, 6, 1, padding=1, candidate_config={'channel': (3, 6)}), fixed=True) ] with supernet(kernel_size=(3, 5, 7), expand_ratio=(1, 2, 4)) as ofa_super: models1 = [] models1 += [nn.Conv2D(6, 4, 3)] models1 += [nn.BatchNorm(4)] models1 += [ReLU()] models1 += [nn.Conv2D(4, 4, 3, groups=2)] models1 += [nn.InstanceNorm(4)] models1 += [ReLU()] models1 += [nn.Conv2DTranspose(4, 4, 3, groups=2)] models1 += [nn.BatchNorm(4)] models1 += [ReLU()] models1 += [nn.Conv2DTranspose(4, 4, 3)] models1 += [nn.BatchNorm(4)] models1 += [ReLU()] models1 = ofa_super.convert(models1) models += models1 self.models = paddle.nn.Sequential(*models)
def __init__(self, in_planes, out_planes, stride=1): super(Block, self).__init__() self.conv1 = nn.Conv2D(in_planes, in_planes, filter_size=3, stride=stride, padding=1, groups=in_planes, bias_attr=False) self.bn1 = nn.InstanceNorm(in_planes) self.conv2 = nn.Conv2D(in_planes, out_planes, filter_size=1, stride=1, padding=0) self.bn2 = nn.InstanceNorm(out_planes)
def __init__(self): super(MobileNet, self).__init__() self.conv1 = nn.Conv2D(shape[0], shape[0], filter_size=3, stride=1, padding=1, bias_attr=False) self.bn1 = nn.InstanceNorm(shape[0]) self._layers = self._make_layers(in_planes=shape[0]) self.conv_last = nn.Conv2D(shape[0], shape[0], filter_size=3, stride=1, padding=1, bias_attr=False)