Skip to content

Coding mistake #54

@hlxs-c

Description

@hlxs-c

File: Codes/ch03/01_main-chapter-code/ch03.ipynb

CausalAttention 类中的forward方法,对注意力分数进行softmax的部分有问题:
image

这里如果设置为dim=1,就不能处理批次情况了。在输入的形状为[batch_size, num_tokens, d_in] 时,attn_scores的形状为[batch_size, num_tokens, num_tokens],此时应该是在dim=2上进行softmax才是正确吧,所以应该为dim=-1。

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