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

Adv training #24

Merged
merged 11 commits into from
Sep 11, 2024
Merged

Adv training #24

merged 11 commits into from
Sep 11, 2024

Conversation

rithik83
Copy link
Collaborator

@rithik83 rithik83 commented Aug 30, 2024

Solves issue #23. I have described as well as I can the issue, let me know if it's confusing.

Currently seems as though FGSM training actually works. Will test PGD training soon.

Edit: PGD training seems to work too. Only thing is if the adversary in train-time is too strong, the model doesn't seem to want to learn anything.

Also based on a few runs, what i notice looks like it makes sense. Classical training performs poorly on both FGSM and PGD adversaries. FGSM training does decent against FGSM adversary but poorly against PGD. PGD training did well against both. Checks out

@rithik83 rithik83 marked this pull request as draft August 30, 2024 01:00
@rithik83 rithik83 self-assigned this Aug 30, 2024
@rithik83 rithik83 added the enhancement New feature or request label Aug 30, 2024
@rithik83 rithik83 marked this pull request as ready for review August 30, 2024 21:40
Copy link

codecov bot commented Sep 4, 2024

Codecov Report

Attention: Patch coverage is 9.52381% with 19 lines in your changes missing coverage. Please review.

Project coverage is 40.66%. Comparing base (a02d3e9) to head (36c06b7).
Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
src/training/adversarial_training.jl 0.00% 13 Missing ⚠️
src/attacks/square/square_attack.jl 0.00% 5 Missing ⚠️
src/attacks/square/utils.jl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #24      +/-   ##
==========================================
- Coverage   41.32%   40.66%   -0.66%     
==========================================
  Files          10       10              
  Lines         242      241       -1     
==========================================
- Hits          100       98       -2     
- Misses        142      143       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rithik83 rithik83 requested a review from pat-alt September 5, 2024 14:09
Copy link
Member

@pat-alt pat-alt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM although you could perhaps still add tests for the training functions? Guess local and manual testing is also sufficient for now though

)
θ = Flux.params(model)
vanilla_losses = []
train_loader = DataLoader((x_train, y_train), batchsize = batch_size, shuffle = true)
train_loader = DataLoader((x_train, y_train), batchsize = batch_size, shuffle = true) |> gpu
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be Flux.get_device() to keep it general? https://fluxml.ai/Flux.jl/stable/guide/gpu/#Using-device-objects

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat, didn't know that was a thing. I'll change this, and I'll also add some tests for the train, and the attacks (simple ones for now to check if the perturbation is within bounds)

clamp_range = (0, 1),
)
adv_losses = []
θ = Flux.params(model)
train_loader = DataLoader((x_train, y_train), batchsize = batch_size, shuffle = true)
train_loader = DataLoader((x_train, y_train), batchsize = batch_size, shuffle = true) |> gpu
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

@rithik83 rithik83 merged commit 6ae3f97 into main Sep 11, 2024
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants