IBM / BadDiffusion

Official repo to reproduce the paper "How to Backdoor Diffusion Models?" published at CVPR 2023
Apache License 2.0
76 stars 5 forks source link

Loss function of poisoning data not found #13

Closed chengyiqiu1121 closed 4 months ago

chengyiqiu1121 commented 4 months ago
if loss_type == 'l1':
    loss = F.l1_loss(target, predicted_noise)
elif loss_type == 'l2':
    loss = F.mse_loss(target, predicted_noise)
elif loss_type == "huber":
    loss = F.smooth_l1_loss(target, predicted_noise)

I see you user L-2 to optimize the noice predictor, which is as same as paper. But i could not find the loss function of poisoning data.

截屏2024-04-21 18 54 50
FrankCCCCC commented 4 months ago

Hi, thank you for your interest. The loss function for the poisoning data is at Line 257, the function q_sample_diffuser. The target in Line 293 is $\frac{\rho_t \sigma_t}{1-\alpha_t} \mathbf{r} + \epsilon$ and the x_noisy is $\mathbf{x}_{t}'(\mathbf{y}, \mathbf{y}, \epsilon)$. Let me know if you have further questions.

chengyiqiu1121 commented 4 months ago

Oh I see, it is kind of you, thank you very much. This is really helpful to me :)