args = parser.parse_args() print(args) device = "cuda" set_seed(0) trainset, normalize, unnormalize = str2dataset(args.dataset, train=True) trainloader = torch.utils.data.DataLoader(trainset, batch_size=args.batch_size, shuffle=True, num_workers=2) net = str2model(path=args.save_model_loc, dataset=args.dataset, pretrained=args.resume).eval().to(device) if args.attack == "frank": attacker = FrankWolfe(predict=lambda x: net(normalize(x)), loss_fn=nn.CrossEntropyLoss(reduction="sum"), eps=args.eps, kernel_size=5, nb_iter=args.nb_iter, entrp_gamma=1e-3, dual_max_iter=30, grad_tol=1e-4, int_tol=1e-4, device=device, postprocess=False, verbose=False)
parser.add_argument('--seed', type=int, default=0) parser.add_argument('--postprocess', type=str2bool, default=False) args = parser.parse_args() print(args) device = "cuda" set_seed(args.seed) testset, normalize, unnormalize = str2dataset(args.dataset, train=True) testloader = torch.utils.data.DataLoader(testset, batch_size=args.batch_size, shuffle=False, num_workers=0) net = str2model(args.checkpoint, dataset=args.dataset, pretrained=True).eval().to(device) for param in net.parameters(): param.requires_grad = False sinkhorn = Sinkhorn(predict=lambda x: net(normalize(x)), loss_fn=nn.CrossEntropyLoss(reduction="sum"), eps=args.eps, kernel_size=args.kernel_size, lr=args.lr, nb_iter=args.nb_iter, lam=args.lam, sinkhorn_max_iter=args.sinkhorn_max_iter, stop_abs=args.stop_abs, stop_rel=args.stop_rel, device=device,