摘要: 注意力层: ``` 输入 -> LLQ -> @ -> /√ES -> softmax -> @ -> LLO -> Dropout -> 输出 | ↑ ↑ + > LLK + | | | + > LLV + ``` FFN 层: ``` 输入 -> LL1 -> GELU -> Dropout - 阅读全文
posted @ 2023-06-26 15:40 绝不原创的飞龙 阅读(27) 评论(0) 推荐(0) 编辑
摘要: ```py # Bert 编码器模块 # 由一个嵌入层和 NL 个 TF 层组成 class BERT(nn.Module): """ BERT model : Bidirectional Encoder Representations from Transformers. """ def __in 阅读全文
posted @ 2023-06-26 15:19 绝不原创的飞龙 阅读(20) 评论(0) 推荐(0) 编辑
摘要: ```py # PFF 层,基本相当于两个全连接 # 每个 TF 块中位于注意力层之后 class PositionwiseFeedForward(nn.Module): "Implements FFN equation." def __init__(self, d_model, d_ff, dro 阅读全文
posted @ 2023-06-26 14:40 绝不原创的飞龙 阅读(54) 评论(0) 推荐(0) 编辑