eta=1.05,
         beta=0.9,
         eps=10.,
     )),
]  # each element in the list is the tuple (attack_class, attack_kwargs)

mnist_clntrained_model = get_mnist_lenet5_clntrained().to(device)
mnist_advtrained_model = get_mnist_lenet5_advtrained().to(device)
mnist_test_loader = get_mnist_test_loader(batch_size=batch_size)

lst_setting = [
    (mnist_clntrained_model, mnist_test_loader),
    (mnist_advtrained_model, mnist_test_loader),
]

info = get_benchmark_sys_info()

lst_benchmark = []
for model, loader in lst_setting:
    for attack_class, attack_kwargs in lst_attack:
        lst_benchmark.append(
            benchmark_margin(model,
                             loader,
                             attack_class,
                             attack_kwargs,
                             norm=attack_kwargs["norm"]))

print(info)
for item in lst_benchmark:
    print(item)
batch_size = 100
device = "cuda"

lst_attack = [
    (DDNL2Attack, dict(
        nb_iter=1000, gamma=0.05, init_norm=1., quantize=True, levels=256,
        clip_min=0., clip_max=1., targeted=False)),
]  # each element in the list is the tuple (attack_class, attack_kwargs)

mnist_clntrained_model = get_mnist_lenet5_clntrained().to(device)
mnist_advtrained_model = get_mnist_lenet5_advtrained().to(device)
mnist_test_loader = get_mnist_test_loader(batch_size=batch_size)

lst_setting = [
    (mnist_clntrained_model, mnist_test_loader),
    (mnist_advtrained_model, mnist_test_loader),
]


info = get_benchmark_sys_info()

lst_benchmark = []
for model, loader in lst_setting:
    for attack_class, attack_kwargs in lst_attack:
        lst_benchmark.append(benchmark_margin(
            model, loader, attack_class, attack_kwargs, norm=2, device="cuda"))

print(info)
for item in lst_benchmark:
    print(item)
Beispiel #3
0
    (CarliniWagnerLinfAttack,
     dict(num_classes=10, max_iterations=500, max_const=0.1,
          return_best=True)),
]  # each element in the list is the tuple (attack_class, attack_kwargs)

mnist_clntrained_model = get_mnist_lenet5_clntrained().to(device)
mnist_advtrained_model = get_mnist_lenet5_advtrained().to(device)
mnist_test_loader = get_mnist_test_loader(batch_size=batch_size)

lst_setting = [
    (mnist_clntrained_model, mnist_test_loader),
    (mnist_advtrained_model, mnist_test_loader),
]

info = get_benchmark_sys_info()

lst_benchmark = []
for model, loader in lst_setting:
    for attack_class, attack_kwargs in lst_attack:
        lst_benchmark.append(
            benchmark_margin(model,
                             loader,
                             attack_class,
                             attack_kwargs,
                             "inf",
                             device="cuda"))

print(info)
for item in lst_benchmark:
    print(item)
Beispiel #4
0
     dict(nb_iter=1000,
          gamma=0.05,
          init_norm=1.,
          quantize=True,
          levels=256,
          clip_min=0.,
          clip_max=1.,
          targeted=False)),
]  # each element in the list is the tuple (attack_class, attack_kwargs)

mnist_clntrained_model = get_mnist_lenet5_clntrained().to(device)
mnist_advtrained_model = get_mnist_lenet5_advtrained().to(device)
mnist_test_loader = get_mnist_test_loader(batch_size=batch_size)

lst_setting = [
    (mnist_clntrained_model, mnist_test_loader),
    (mnist_advtrained_model, mnist_test_loader),
]

info = get_benchmark_sys_info()

lst_benchmark = []
for model, loader in lst_setting:
    for attack_class, attack_kwargs in lst_attack:
        lst_benchmark.append(
            benchmark_margin(model, loader, attack_class, attack_kwargs, 2))

print(info)
for item in lst_benchmark:
    print(item)