Handle the case where no adversarial samples are generated. This causes error with numpy.vstack.
Filter the rows of data_numpy with mask_valid before calculating the average norm-diff.
Do not skip a batch if there are some valid adversarial samples. Checking num_valid = 0 before skipping a batch.
Filter target_numpy by mask_valid before calculating the label mismatch.
Move the accumulation of adv_examples into total after the accumulation of labels. This ensures that there is no size mismatch between the final arrays total and total_mismatch.
Returning the clean data and labels corresponding to valid adversarial samples, and saving them to numpy files.
Handle the case where no adversarial samples are generated. This causes error with
numpy.vstack
.Filter the rows of
data_numpy
withmask_valid
before calculating the average norm-diff.Do not skip a batch if there are some valid adversarial samples. Checking
num_valid = 0
before skipping a batch.Filter
target_numpy
bymask_valid
before calculating the label mismatch.Move the accumulation of
adv_examples
intototal
after the accumulation of labels. This ensures that there is no size mismatch between the final arraystotal
andtotal_mismatch
.Returning the clean data and labels corresponding to valid adversarial samples, and saving them to numpy files.