fra31 / auto-attack

Code relative to "Reliable evaluation of adversarial robustness with an ensemble of diverse parameter-free attacks"
https://arxiv.org/abs/2003.01690
MIT License
656 stars 112 forks source link

More efficient projections for FAB #35

Closed jeromerony closed 3 years ago

jeromerony commented 3 years ago

Hi!

As the title says, here are slightly more efficient projections used in FAB. The main differences for the implementation are:

Cheers

fra31 commented 3 years ago

Hi,

thanks for the contribution! I'll try to quickly have a look and merge it. Do you roughly know which is the improvement in terms of time?

jeromerony commented 3 years ago

Sorry, I should have included them in the first place.

I ran a few benchmarks on a Titan RTX. First a synthetic benchmark for the projections alone (with cudnn.benchmark enabled). The results are the following (time in seconds) given the same data: Projection Original New
L1 1.79 0.522
L2 0.565 0.35
Linf 0.756 0.338

So the improvements depend on the projections.

In term of run-time for FAB, I tried with the eval script (ResNet-18, 1000 samples of CIFAR10, Linf at 1/255) and, with the new projections, the attack is about 2% faster (317.6s instead of 323.6s) with cudnn.benchmark enabled. Obviously this difference is going to be smaller for larger models and vice versa.

fra31 commented 3 years ago

Ok, thanks a lot, that's a significant improvement.

Yeah, for the full attack anyway the other computations should dominate in terms of time. But it makes definitely sense to have more efficient projections in general.

jeromerony commented 3 years ago

I made some other minor optimizations. It does not change much but it's a bit cleaner.

fra31 commented 3 years ago

Ok, I ran some tests and the new projections seem equivalent to the old ones, but significantly faster.

Thanks again for the contribution!