BardOfCodes / universal_pytorch

Pytorch implementation of Universal Adverserial Perturbation and Fast Feature Fool
22 stars 2 forks source link

How to set the parameter num_classes? #1

Open machanic opened 5 years ago

machanic commented 5 years ago

In ImageNet dataset, there are 1000 classes in total, but when I set num_classes in Universal, the algorithm runs too slow, because it will iterate over 1000 times in deepfool.py

BardOfCodes commented 5 years ago

Hi @sharpstill! You don't actually need to iterate over the entire set of 1,000 classes. The iteration happens over the sorted set of classes, to find which class gives the minimal perturbation. It is highly unlikely to achieve a minimal perturbation from any class which has rank higher than 10 in the sorted set of probabilities. Hence you should be able to get approximately the same result from iterating over 10 classes, as from iterating over 1000 classes.

I would suggest testing out this hypothesis on a small set of images!