mirror of
https://github.com/rasbt/LLMs-from-scratch.git
synced 2026-04-10 12:33:42 +00:00
small readability updates
This commit is contained in:
@@ -61,7 +61,7 @@
|
||||
" values = x @ self.W_value\n",
|
||||
" \n",
|
||||
" attn_scores = queries @ keys.T # omega\n",
|
||||
" attn_weights = torch.softmax(attn_scores / self.d_out**0.5, dim=-1)\n",
|
||||
" attn_weights = torch.softmax(attn_scores / keys.shape[-1]**0.5, dim=-1)\n",
|
||||
"\n",
|
||||
" context_vec = attn_weights @ values\n",
|
||||
" return context_vec\n",
|
||||
@@ -92,7 +92,7 @@
|
||||
" values = self.W_value(x)\n",
|
||||
" \n",
|
||||
" attn_scores = queries @ keys.T\n",
|
||||
" attn_weights = torch.softmax(attn_scores / self.d_out**0.5, dim=1)\n",
|
||||
" attn_weights = torch.softmax(attn_scores / keys.shape[-1]**0.5, dim=1)\n",
|
||||
"\n",
|
||||
" context_vec = attn_weights @ values\n",
|
||||
" return context_vec\n",
|
||||
|
||||
Reference in New Issue
Block a user