chk_path=chk_path,
            poison_idxes=base_idx_list,
            poison_label=args.poison_label,
            tol=args.tol,
            end2end=args.end2end,
            start_ite=args.resume_poison_ite,
            poison_init=poison_init,
            mode=args.mode,
            net_repeat=args.net_repeat)
        tt = time.time()

    res = []
    print("Evaluating against victims networks")
    for tnet, tnet_name in zip(targets_net, args.target_net):
        print(tnet_name)
        pred = train_network_with_poison(tnet,
                                         target,
                                         poison_tuple_list,
                                         base_idx_list,
                                         chk_path,
                                         args,
                                         save_state=False)
        res.append(pred)
        print("--------")

    print("------SUMMARY------")
    print("TIME ELAPSED (mins): {}".format(int((tt - t) / 60)))
    print("TARGET INDEX: {}".format(args.target_index))
    for tnet_name, r in zip(args.target_net, res):
        print(tnet_name, int(r == args.poison_label))
Example #2
0
        poison_tuple_list = \
            make_convex_polytope_poisons(sub_net_list, victim_net, base_tensor_list, targets,
                                         targets_indices, device=args.device,
                                         opt_method=args.poison_opt,
                                         lr=args.poison_lr, momentum=args.poison_momentum, iterations=args.poison_ites,
                                         epsilon=args.poison_epsilon, decay_ites=args.poison_decay_ites,
                                         mean=torch.Tensor(cifar_mean).reshape(1, 3, 1, 1),
                                         std=torch.Tensor(cifar_std).reshape(1, 3, 1, 1),
                                         decay_ratio=args.poison_decay_ratio, chk_path=chk_path, end2end=args.end2end,
                                         poison_idxes=base_idx_list, poison_label=args.poison_label, mode=args.mode,
                                         tol=args.tol, start_ite=args.resume_poison_ite, poison_init=poison_init, net_repeat=args.net_repeat)

        tt = time.time()

    res = []
    print("Evaluating against victims networks")
    for vnet, vnet_name in zip(targets_net, args.victim_net):
        print(vnet_name)
        attack_acc, attack_val_acc = train_network_with_poison(vnet, targets, targets_indices, poison_tuple_list,
                                                               base_idx_list, chk_path,
                                                               args, save_state=False, eval_targets=eval_targets)

        res.append((attack_acc, attack_val_acc))
        print("--------")

    print("------SUMMARY------")
    print("TIME ELAPSED (mins): {}".format(int((tt - t) / 60)))
    print("TARGET INDEX: {}".format(args.target_index))
    for tnet_name, (attack_acc, attack_val_acc) in zip(args.victim_net, res):
        print(tnet_name, attack_acc, attack_val_acc)