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

Two problems in training code of ImageNetMini #7

Closed
ZhengyuZhao opened this issue Nov 15, 2021 · 1 comment
Closed

Two problems in training code of ImageNetMini #7

ZhengyuZhao opened this issue Nov 15, 2021 · 1 comment

Comments

@ZhengyuZhao
Copy link

  1. In line 173 of main.py, 20% of the PoisonImageNetMini were selected as the training data but with "shuffle=True", then how could you make sure these data are exactly the same 20% of the data that have been used for generating the noise?

  2. I also find the same problem about the sample-wise noise as the one mentioned in A problem when training model on ImageNetMini #5.
    in line 634 of dataset.py:

if self.poison_samples[index]:
            noise = self.perturb_tensor[target]
            sample = sample + noise
            sample = np.clip(sample, 0, 255)

so by using 'target' as the index, the perturb_tensor[target] will only select one of the top '0~99' components of the perturb_tensor, and add the same noise to all samples that are from the same [target] class. In this way, it definitely does it wrong but can lead to good results because it is doing class-wise noise.

@HanxunH
Copy link
Owner

HanxunH commented Nov 16, 2021

Hi,

For Q1, np.random.seed(seed) can make sure the randomly selected samples are the same. Make sure to use the same seed.

For Q2, yes, that is an implementation error, target should be replaced with index, using target is class-wise noise. Need to add an extra variable to distinguish the class-wise and sample-wise noise in this case, I will look into it.

@HanxunH HanxunH closed this as completed Sep 16, 2022
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