跳到正文
r/MachineLearning· /u/ifaposto·· 3 小时前AI 评分53

作者在 PyTorch 中手写 Transformer 自动求导实现

Understanding Transformer Autograd by Building It Manually in PyTorch [P]

AI 导读

作者在 PyTorch 中上传了一个最小且自包含的 Transformer 分类器手写 autograd 实现,帮助理解 autograd 底层在做什么。该实现可作为低层微分的手动参考,用于编写自定义反向传播并追踪梯度如何流经注意力模块,代码在 GitHub 和 Colab 上公开。

正文

I’ve uploaded a minimal, self-contained implementation of manual autograd for a transformer-based classifier in PyTorch. It can help build intuition for what autograd is doing under the hood and is a useful hands-on reference for low-level differentiation in Transformer models, such as writing custom backward passes and tracing how gradients flow through attention blocks.

🐙 GitHub:

https://github.com/ifiaposto/transformer_custom_autograd/tree/main

📓 Colab:

https://colab.research.google.com/drive/1Lt7JDYG44p7YHJ76eRH_8QFOPkkoIwhn

submitted by /u/ifaposto
[link] [留言]

来源:r/MachineLearning · reddit.com