题库/手撕 Self-Attention

手撕 Self-Attention

Hard
经典手撕transformerdeep-learningattention
题目描述

题目描述

实现 Scaled Dot-Product Attention 机制。

思路分析

Q、K、V 三个矩阵,计算 softmax(QK^T / sqrt(d_k)) * V。

solution.py
输出
点击「运行」按钮执行代码