Release: 2026/10/02 17:40 Reading: 0
Original author:Mehdi Hosseini Moghadam
Original source:https://www.youtube.com/embed/Gi8u8ET7ghY
Attention, multi-head attention and the full Transformer, explained from zero and coded from scratch in PyTorch, with every step worked by hand on a tiny example and every tensor shape on screen. We start with why recurrent networks struggled, turn words into vectors, and build attention one step at a time: dot products, softmax, queries, keys and values, why we divide by the square root of d_k, causal and padding masks. Then multi-head attention: splitting 512 dimensions into 8 heads of 64, the shapes after every line of code, and a check against PyTorch's own nn.MultiheadAttention. Next the rest of the Transformer: sinusoidal positional encodings, residual connections and LayerNorm, the feed-forward block, encoder and decoder layers, cross-attention and the full architecture. Finally we train it live on a GPU, decode step by step and look at the attention maps it learned. Key takeaway: attention lets every token look at every other token in one step, and that is the whole Transformer. Timeline 0:00 - 3:55 Why attention 3:55 - 7:35 Words become vectors 7:35 - 16:07 Attention, step by step 16:07 - 19:12 Masks 19:12 - 26:50 Multi-head attention 26:50 - 32:48 Positions, norms and feed-forward 32:48 - 38:25 The full Transformer 38:25 - 44:30 Training and inference 44:30 - 46:50 Summary Subscribe for more: https://www.youtube.com/@mehdihosseinimoghadam GitHub: https://github.com/mehdihosseinimoghadam LinkedIn: https://linkedin.com/in/mehdi-hosseini-moghadam-384912198 #Transformer #Attention #SelfAttention #MultiHeadAttention #PyTorch #DeepLearning #MachineLearning #LLM #NLP #AI #Python #AttentionIsAllYouNeed #ArtificialIntelligence
E_SHUVO
2026-10-02 19:14
Stock Inspired Live
2026-10-02 19:14
CryptoTuts
2026-10-02 19:14
加密仲达—比特币行情分析
2026-10-02 19:14
愿长安剧社HopeDrama
2026-10-02 19:14
燃漫前線 BladeAnime
2026-10-02 18:56
Mehdi Hosseini Moghadam
2026-10-02 18:35
Agentic Loop
2026-10-02 18:35
StateCash TV
2026-10-02 18:35
Select Currency
US Dollar
USD
Chinese Yuan
CNY
Japanese Yen
JPY
South Korean Won
KRW
New Taiwan Dollar
TWD
Canadian Dollar
CAD
Euro
EUR
Pound Sterling
GBP
Danish Krone
DKK
Hong Kong Dollar
HKD
Australian Dollar
AUD
Brazilian Real
BRL
Swiss Franc
CHF
Chilean Peso
CLP
Czech Koruna KČ
CZK
Singapore Dollar
SGD
Indian Rupee
INR
Saudi Riyal
SAR
Vietnamese Dong
VND
Thai Baht
THB
Select Currency
US Dollar
USD-$
Chinese Yuan
CNY-¥
Japanese Yen
JPY-¥
South Korean Won
KRW -₩
New Taiwan Dollar
TWD-NT$
Canadian Dollar
CAD-$
Euro
EUR - €
Pound Sterling
GBP-£
Danish Krone
DKK-KR
Hong Kong Dollar
HKD- $
Australian Dollar
AUD-$
Brazilian Real
BRL -R$
Swiss Franc
CHF -FR
Chilean Peso
CLP-$
Czech Koruna KČ
CZK -KČ
Singapore Dollar
SGD-S$
Indian Rupee
INR -₹
Saudi Riyal
SAR -SAR
Vietnamese Dong
VND-₫
Thai Baht
THB -฿