コード例 #1
0
for i in range(len(display)):
    l = lam[i]
    disp = display[i]
    a = alpha[i]
    img_perturbed = CW_attack_fast(
        img_0=Y,
        mean_cat_attack=mean_cat_attack,
        cov_cat_attack=cov_cat_attack,
        pi_cat_attack=pi_cat_attack,
        mean_grass_attack=mean_grass_attack,
        cov_grass_attack=cov_grass_attack,
        pi_grass_attack=pi_grass_attack,
        mean_cat_defense=mean_cat_defense,
        cov_cat_defense=cov_cat_defense,
        pi_cat_defense=pi_cat_defense,
        mean_grass_defense=mean_grass_defense,
        cov_grass_defense=cov_grass_defense,
        pi_grass_defense=pi_grass_defense,
        original_img=Y,
        truth=truth,
        l=l,
        alpha=a,
        display_iter=disp,
        stride=stride,
        title="lamda_{}_stride_{}_".format(l, stride),
        path="./Outputs/Defense/AdversarialTraining/" + args.train + '/' +
        args.attack_type + "/")

    display_image(img_perturbed=img_perturbed,
                  mean_cat=mean_cat_defense,
                  cov_cat=cov_cat_defense,
コード例 #2
0
    l = lam[i]
    disp = display[i]
    a = alpha[i]
    img_perturbed = CW_attack_fast(
        img_0=Y,
        mean_cat_attack=mean_cat_attack,
        cov_cat_attack=cov_cat_attack,
        pi_cat_attack=pi_cat_attack,
        mean_grass_attack=mean_grass_attack,
        cov_grass_attack=cov_grass_attack,
        pi_grass_attack=pi_grass_attack,
        mean_cat_defense=mean_cat_defense,
        cov_cat_defense=cov_cat_defense,
        pi_cat_defense=pi_cat_defense,
        mean_grass_defense=mean_grass_defense,
        cov_grass_defense=cov_grass_defense,
        pi_grass_defense=pi_grass_defense,
        original_img=Y,
        truth=truth,
        l=l,
        alpha=a,
        display_iter=disp,
        stride=stride,
        title="lamda_{}_stride_{}_".format(l, stride),
        preprocessing=[None, None],
        path="./Outputs/Defense/AdversarialQuantize/" + args.train + '/' +
        str(args.n_bits) + 'bit/' + args.attack_type + '/',
        attack_type=args.attack_type)

    display_image(img_perturbed=img_perturbed,
                  mean_cat=mean_cat_defense,
for i in range(len(display)):
    l = lam[i]
    disp = display[i]
    a = alpha[i]
    img_perturbed = CW_attack_fast(
        img_0=Y,
        mean_cat_attack=mean_cat_attack,
        cov_cat_attack=cov_cat_attack,
        pi_cat_attack=pi_cat_attack,
        mean_grass_attack=mean_grass_attack,
        cov_grass_attack=cov_grass_attack,
        pi_grass_attack=pi_grass_attack,
        mean_cat_defense=mean_cat_defense,
        cov_cat_defense=cov_cat_defense,
        pi_cat_defense=pi_cat_defense,
        mean_grass_defense=mean_grass_defense,
        cov_grass_defense=cov_grass_defense,
        pi_grass_defense=pi_grass_defense,
        original_img=Y,
        truth=truth,
        l=l,
        alpha=a,
        display_iter=disp,
        stride=stride,
        title="lamda_{}_stride_{}_".format(l, stride),
        preprocessing=[ht, ht_img],
        path="./Outputs/Defense/Halftone/" + args.attack_type + "/",
        attack_type=args.attack_type)

    display_image(img_perturbed=img_perturbed,
                  mean_cat=mean_cat_defense,
                  cov_cat=cov_cat_defense,
### Analysis for Lamda variation
display = [5, 5,2]
lam=[0.5, 1, 5]
for i in range(len(display)): 
    l = lam[i]
    disp = display[i] 
    img_perturbed = CW_attack_fast(   img_0=Y, 
                                      mean_cat_attack=mean_cat, 
                                      cov_cat_attack=cov_cat, 
                                      pi_cat_attack=pi_cat, 
                                      mean_grass_attack=mean_grass,
                                      cov_grass_attack=cov_grass, 
                                      pi_grass_attack=pi_grass,
                                      mean_cat_defense = mean_cat,
                                      cov_cat_defense = cov_cat,
                                      pi_cat_defense = pi_cat,
                                      mean_grass_defense = mean_grass,
                                      cov_grass_defense = cov_grass,
                                      pi_grass_defense = pi_grass,
                                      path = './Outputs/rough/',
                                      original_img = Y,
                                      truth = truth,
                                      l=l, 
                                      display_iter=disp, 
                                      stride=stride, 
                                      title="lamda_{}_stride_{}_".format(l,stride))
    display_image(img_perturbed = img_perturbed, 
                  mean_cat=mean_cat, 
                  cov_cat=cov_cat, 
                  pi_cat=pi_cat, 
                  mean_grass=mean_grass,
                  cov_grass=cov_grass, 
コード例 #5
0
### Analysis for Lamda variation
display = [50, 10, 5]
lam = [1, 5, 10]
for i in range(len(display)):
    l = lam[i]
    disp = display[i]
    img_perturbed = CW_attack_fast(img_0=Y,
                                   mean_cat=mean_cat,
                                   cov_cat=cov_cat,
                                   pi_cat=pi_cat,
                                   mean_grass=mean_grass,
                                   cov_grass=cov_grass,
                                   pi_grass=pi_grass,
                                   mean_cat_infer=mean_cat,
                                   cov_cat_infer=cov_cat,
                                   pi_cat_infer=pi_cat,
                                   mean_grass_infer=mean_grass,
                                   cov_grass_infer=cov_grass,
                                   pi_grass_infer=pi_grass,
                                   original_img=Y,
                                   truth=truth,
                                   l=l,
                                   display_iter=disp,
                                   stride=stride,
                                   title="lamda_{}_stride_{}_".format(
                                       l, stride))

    display_image(img_perturbed=img_perturbed,
                  mean_cat=mean_cat,
                  cov_cat=cov_cat,
                  pi_cat=pi_cat,
                  mean_grass=mean_grass,