Skip to content

attn_base和attn_repalce的选择 #30

Open

Description

@MingsiWang

我可以更换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:])

Activity

  1. WindVChen commented on Nov 15, 2024

    @WindVChen
    Owner

    哈喽 @MingsiWang ,

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions