Skip to content

代码上的困惑 #5

@Liusj-gh

Description

@Liusj-gh

ChannelAttentionBlock函数部分的代码不能理解,还请作者答疑解惑。
困惑的代码为
affinity = torch.matmul(proj_query, proj_key)
affinity_new = torch.max(affinity, -1, keepdim=True)[0].expand_as(affinity) - affinity
affinity_new = self.softmax(affinity_new)
为什么要减去affinity得到affinity_new?这样做不就使得affinity低的channel获得更高的权重吗?这不就与原本的目的背道而驰了吗?
您的文章里也并没有详细说明这一个运算的意义,所以本人无法理解该部分代码。
还请作者指点迷津。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions