示例#1
0
    if not os.path.exists("attack_arrays_0%"):
        os.makedirs("attack_arrays_0%")
    # load attack    

    from attack import Attack
    sys.path.append("./attack-master")
    adversary = Attack(model, eot_iter=args.eot,norm=args.norm, eps=args.epsilon, restarts = args.restarts, attacks_to_run=args.attacks_to_run)
    
    l = [x for (x, y) in test_loader]
    x_test = torch.cat(l, 0)
    l = [y for (x, y) in test_loader]
    y_test = torch.cat(l, 0)
    
    # cheap version
    if args.cheap:
        adversary.cheap()
    
    # plus version
    if args.plus:
        adversary.plus = True
    if args.take_threshold_from_file:
        THRESHOLD = '../threshold.txt'
        log_file = open(THRESHOLD,'r')
        mssg = int(log_file.read())
        print("Taking the threshold value from the threshold file")
        print("The threshold value is:",int(mssg)+1)
        args.threshold = int(mssg)+1

    with torch.no_grad():
        if not args.individual: