mirror of
https://github.com/rasbt/LLMs-from-scratch.git
synced 2026-04-10 12:33:42 +00:00
Rename drop_resid to drop_shortcut (#136)
This commit is contained in:
committed by
GitHub
parent
70cd174091
commit
97ed38116a
@@ -950,21 +950,21 @@
|
||||
" self.ff = FeedForward(cfg)\n",
|
||||
" self.norm1 = LayerNorm(cfg[\"emb_dim\"])\n",
|
||||
" self.norm2 = LayerNorm(cfg[\"emb_dim\"])\n",
|
||||
" self.drop_resid = nn.Dropout(cfg[\"drop_rate\"])\n",
|
||||
" self.drop_shortcut = nn.Dropout(cfg[\"drop_rate\"])\n",
|
||||
"\n",
|
||||
" def forward(self, x):\n",
|
||||
" # Shortcut connection for attention block\n",
|
||||
" shortcut = x\n",
|
||||
" x = self.norm1(x)\n",
|
||||
" x = self.att(x) # Shape [batch_size, num_tokens, emb_size]\n",
|
||||
" x = self.drop_resid(x)\n",
|
||||
" x = self.drop_shortcut(x)\n",
|
||||
" x = x + shortcut # Add the original input back\n",
|
||||
"\n",
|
||||
" # Shortcut connection for feed forward block\n",
|
||||
" shortcut = x\n",
|
||||
" x = self.norm2(x)\n",
|
||||
" x = self.ff(x)\n",
|
||||
" x = self.drop_resid(x)\n",
|
||||
" x = self.drop_shortcut(x)\n",
|
||||
" x = x + shortcut # Add the original input back\n",
|
||||
"\n",
|
||||
" return x"
|
||||
@@ -1489,7 +1489,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.4"
|
||||
"version": "3.10.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
Reference in New Issue
Block a user