Trustworthy-AI-Group / TransferAttack

TransferAttack is a pytorch framework to boost the adversarial transferability for image classification.
MIT License
268 stars 41 forks source link

请教目标攻击中的logit损失问题 #67

Closed sevenPot7 closed 4 months ago

sevenPot7 commented 4 months ago

目标攻击中的logit损失大多都是如下这样写

real = logits.gather(1,label.unsqueeze(1)).squeeze(1)
logit_dists = ( -1 * real)
loss = logit_dists.sum()

请问为什么要求sum()? 如果改成mean()会对结果有影响吗?

xiaosen-wang commented 4 months ago

The primary distinction between using the sum and mean functions to compute gradients lies merely in a constant factor. When the sign function is employed in the attack, this difference does not impact the overall performance.

zqyjww commented 1 month ago

May I ask if I can try to generate adversarial samples using ResNet50 or ResNet152 as proxy models? For example, Python main. py -- input_ir/ path/to/data --output_dir adv_data/logit/resnet18_targeted --attack logit --model=resnet50 --targeted