def build(self):
     network1 = SimpleNet1(in_ch=1, out_ch=10)
     network2 = SimpleNet2(in_ch=1, out_ch=10)
     detector1 = SimpleDetector(network1)
     module1 = DAGModule([network1, network2], dependency=[[-1], [0]], output=[1], device=self.device)
     module2 = DAGModule([network1, detector1], dependency=[[-1], [0]], output=[1], device=self.device)
     instance = DefenseInstance(model=module1, detector=module2)
     return instance
 def build(self):
     ITdefense = InputTransformation(degrees=(-30, 30))
     TEdefense = ThermometerEncoding((0, 1), num_space=10)
     Jpegdefense = JpegCompression((0, 1), 30)
     RSdefense = ReverseSigmoid()
     network1 = SimpleNet(in_ch=1, out_ch=10)
     network2 = SimpleNet(in_ch=10, out_ch=10)
     network3 = SimpleNet(in_ch=1, out_ch=10)
     module1 = DAGModule([TEdefense, network2], device=self.device)
     module2 = DAGModule([Jpegdefense, network1, RSdefense], device=self.device)
     module3 = DAGModule([ITdefense, network3], device=self.device)
     losscomb = LossCombine()
     classifier = DAGModule([module1, module2, module3, losscomb], dependency=[[-1], [-1], [-1], [0, 1, 2]],
                          output=[3], device=self.device)
     instance = DefenseInstance(model=classifier)
     return instance
Esempio n. 3
0
 def build(self):
     Jpegdefense = JpegCompression((0, 1), COMPRESSION_QUALITY)
     RSdefense = ReverseSigmoid()
     classifier = DAGModule([Jpegdefense, self.network, RSdefense],
                            device=self.device)
     instance = DefenseInstance(model=classifier, detector=None)
     return instance
 def build(self):
     Jpegdefense = JpegCompression((0, 1), 30)
     RSdefense = ReverseSigmoid()
     network1 = SimpleNet(in_ch=1, out_ch=10)
     classifier = DAGModule([Jpegdefense, network1, RSdefense], device=self.device)
     instance = DefenseInstance(model=classifier, detector=None)
     return instance
 def build(self):
     ITdefense = InputTransformation(degrees=(-30, 30))
     # Varmin = VarianceMinimization(prob=0.3, norm=2)
     # Jpegdefense = JpegCompression((0, 1), 30)
     # RSdefense = ReverseSigmoid()
     network1 = SimpleNet(in_ch=1, out_ch=10)
     classifier = DAGModule([ITdefense, network1], device=self.device)
     instance = DefenseInstance(model=classifier, detector=None)
     return instance
Esempio n. 6
0
 def build(self):
     from zoo.saved_instances.JEM.CCF_model import CCF
     # nsteps = 10
     ITdefense = InputTransformation(degrees=(-ROTATION_DEGREES, ROTATION_DEGREES))
     classifier = DAGModule([ITdefense, self.network], device=self.device)
     # classifier = WrapperModel(f, nsteps).to(self.device)
     # classifier = gradient_attack_wrapper(f)
     # classifier = f.to(self.device)
     # classifier = nn.DataParallel(classifier).to(self.device)
     instance = DefenseInstance(model=classifier, detector=None)
     return instance
Esempio n. 7
0
 def build(self):
     from zoo.saved_instances.JEM.CCF_model import CCF
     Jpegdefense = JpegCompression((0, 1), COMPRESSION_QUALITY)
     RSdefense = ReverseSigmoid()
     classifier = DAGModule([Jpegdefense, self.network, RSdefense], device=self.device)
     # classifier = WrapperModel(f, nsteps).to(self.device)
     # classifier = gradient_attack_wrapper(f)
     # classifier = f.to(self.device)
     # classifier = nn.DataParallel(classifier).to(self.device)
     instance = DefenseInstance(model=classifier, detector=None)
     return instance
 def build(self):
     network1 = ConvMedBig(device=self.device,
                           dataset='cifar10',
                           width1=4,
                           width2=4,
                           width3=4,
                           linear_size=200,
                           input_channel=3,
                           with_normalization=True)
     classifier = DAGModule([network1], device=self.device)
     instance = DefenseInstance(model=classifier, detector=None)
     return instance
 def build(self):
     ITdefense = InputTransformation(degrees=(-30, 30))
     TEdefense = ThermometerEncoding((0, 1), num_space=10)
     Jpegdefense = JpegCompression((0, 1), 30)
     RSdefense = ReverseSigmoid()
     network1 = ConvMedBig(device=self.device,
                           dataset='cifar10',
                           width1=4,
                           width2=4,
                           width3=4,
                           linear_size=200,
                           input_channel=3,
                           with_normalization=True)
     network2 = ConvMedBig(device=self.device,
                           dataset='cifar10',
                           width1=4,
                           width2=4,
                           width3=2,
                           linear_size=200,
                           input_channel=30,
                           with_normalization=False)
     network3 = ConvMedBig(device=self.device,
                           dataset='cifar10',
                           width1=4,
                           width2=4,
                           width3=4,
                           linear_size=200,
                           input_channel=3,
                           with_normalization=True)
     module1 = DAGModule([TEdefense, network2], device=self.device)
     module2 = DAGModule([Jpegdefense, network1, RSdefense],
                         device=self.device)
     module3 = DAGModule([ITdefense, network3], device=self.device)
     losscomb = LossCombine()
     classifier = DAGModule([module1, module2, module3, losscomb],
                            dependency=[[-1], [-1], [-1], [0, 1, 2]],
                            output=[3],
                            device=self.device)
     instance = DefenseInstance(model=classifier)
     return instance
 def build(self):
     TEdefense = ThermometerEncoding((0, 1), num_space=10)
     network1 = ConvMedBig(device=self.device,
                           dataset='cifar10',
                           width1=4,
                           width2=4,
                           width3=2,
                           linear_size=200,
                           input_channel=30,
                           with_normalization=False)
     classifier = DAGModule([TEdefense, network1], device=self.device)
     instance = DefenseInstance(model=classifier, detector=None)
     return instance
 def build(self):
     network = ConvMedBig(device=self.device,
                          dataset='cifar10',
                          width1=4,
                          width2=4,
                          width3=4,
                          linear_size=200,
                          input_channel=3,
                          with_normalization=True)
     network1 = ConvMedBig1(network)
     network2 = ConvMedBig2(network)
     detector1 = SimpleDetector(network1, 200)
     module1 = DAGModule([network1, network2],
                         dependency=[[-1], [0]],
                         output=[1],
                         device=self.device)
     module2 = DAGModule([network1, detector1],
                         dependency=[[-1], [0]],
                         output=[1],
                         device=self.device)
     classifier = module1
     instance = DefenseInstance(model=classifier, detector=module2)
     # return instance
     return instance
 def build(self):
     Jpegdefense = JpegCompression((0, 1), 60)
     RSdefense = ReverseSigmoid()
     network1 = ConvMedBig(device=self.device,
                           dataset='cifar10',
                           width1=4,
                           width2=4,
                           width3=4,
                           linear_size=200,
                           input_channel=3,
                           with_normalization=True)
     classifier = DAGModule([Jpegdefense, network1, RSdefense],
                            device=self.device)
     instance = DefenseInstance(model=classifier, detector=None)
     return instance
 def build(self):
     TEdefense = ThermometerEncoding((0, 1), num_space=10)
     network1 = SimpleNet(in_ch=10, out_ch=10)
     classifier = DAGModule([TEdefense, network1], device=self.device)
     instance = DefenseInstance(model=classifier, detector=None)
     return instance
 def build(self):
     network1 = SimpleNet(in_ch=1, out_ch=10)
     classifier = DAGModule([network1], device=self.device)
     instance = DefenseInstance(model=classifier, detector=None)
     return instance
 def build(self):
     network = resnet.SparseResNet18(sparsities=[0.1, 0.1, 0.1, 0.1],
                                     sparse_func='reg').to(self.device)
     classifier = DAGModule([network], device=self.device)
     instance = DefenseInstance(model=classifier, detector=None)
     return instance
Esempio n. 16
0
 def build(self):
     ITdefense = InputTransformation(degrees=(-ROTATION_DEGREES, ROTATION_DEGREES))
     classifier = DAGModule([ITdefense, self.network], device=self.device)
     instance = DefenseInstance(model=classifier, detector=None)
     return instance