Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Robustness and Custom Dataset #12

Open
hoda213 opened this issue Mar 16, 2021 · 1 comment
Open

Robustness and Custom Dataset #12

hoda213 opened this issue Mar 16, 2021 · 1 comment

Comments

@hoda213
Copy link

hoda213 commented Mar 16, 2021

Hello,
Thank you for sharing this interesting work, I use a custom dataset of RGB images with size 224*224 saved in the 5 label names from 0 to 4 in train/images/0..4 folders and no validation folder and in the training phase. I use the predefined resnet50 architecture + the below parameters

train_kwargs = {
'out_dir': "./train_out",
'adv_train': 1,
'constraint': '2',
'eps': 0.05,
'attack_lr': 1.5,
'attack_steps': 10,
'epochs': 10,
'log_iters':5,
'lr':0.001,
'momentum':0.9,
'weight_decay':1e-3,
'use_best': True,
'random_restarts': 0,
'save_ckpt_iters':-1
}
train.train_model(train_args, model, (train_loader, val_loader), store=out_store)

Then it generates some .pt model files that I used the best version of it for the test phase

# Load model
model_kwargs = {
    'arch': 'resnet50',
    'dataset': ds,
    'resume_path' : './train_out/4bce8667-bc86-4776-aa1d-1489eacda01f/checkpoint.pt.best'
}

model, _ = model_utils.make_and_restore_model(**model_kwargs)
model.eval()
pass

BATCH_SIZE = 32
NUM_WORKERS = 2
_, test_loader = ds.make_loaders(workers=NUM_WORKERS,
                                      batch_size=BATCH_SIZE)

# PGD Parameters
kwargs = {
    #'criterion': ch.nn.CrossEntropyLoss(),
    'custom_loss': activation_loss,
    'constraint':'2',
    'eps': 50,
    'step_size': 0.5,
    'iterations': 200,
    'do_tqdm': True,
    'targeted': True,
}

Then implemented the remained cells of maximizing_inputs notebook but the output representation is completely noisy and the model does not sort the 5 top images based on their labels. Could you please help me with this issue?
Any comments would be appreciated

@andrewilyas
Copy link
Contributor

Hi @hoda213 -- I suspect that the value of $$\epsilon$$ you are using to train is too small. Try training with \epsilon = 0.5 or 1.0, instead of 0.05 (0.05 is typically used for L-infinity attacks). Let me know if this fixes the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants