DiffAttack icon indicating copy to clipboard operation
DiffAttack copied to clipboard

attn_base和attn_repalce的选择

Open MingsiWang opened this issue 1 year ago • 1 comments

我可以更换attn_base和attn_repalce的选择吗,这样选择的理由是什么呢
attn = attn.reshape(self.batch_size, h, *attn.shape[1:]) attn_base, attn_repalce = attn[0], attn[1:] if not is_cross: """ ========================================== ========= Self Attention Control ========= === Details please refer to Section 3.4 == ========================================== """ #调用 replace_self_attention,用 attn_base 替换掉 attn_replace self.loss += self.criterion(attn[1:], self.replace_self_attention(attn_base, attn_repalce)) attn = attn.reshape(self.batch_size * h, *attn.shape[2:])

MingsiWang avatar Nov 15 '24 08:11 MingsiWang

哈喽 @MingsiWang ,

这儿的代码之前写的有些冗余了,实际上self.loss那一行做的工作就是使得attn_baseattn_replace相接近。由于attn_base对应的是original latentattn_replace对应的是optimized latent(应该没记错),通过self.loss就能使得optimized latent的自注意力图与original latent的自注意力图靠近,从而有利于保留图像结构。

WindVChen avatar Nov 15 '24 09:11 WindVChen