mirror of
https://github.com/rasbt/LLMs-from-scratch.git
synced 2025-09-25 16:17:10 +00:00
Comment typo: head_dim -> head_dim // 2
This commit is contained in:
parent
b12dbf6c68
commit
4aa398c79d
@ -453,7 +453,7 @@
|
||||
" x2 = x[..., head_dim // 2 :] # Second half\n",
|
||||
"\n",
|
||||
" # Adjust sin and cos shapes\n",
|
||||
" cos = cos[:seq_len, :].unsqueeze(0).unsqueeze(0) # Shape: (1, 1, seq_len, head_dim)\n",
|
||||
" cos = cos[:seq_len, :].unsqueeze(0).unsqueeze(0) # Shape: (1, 1, seq_len, head_dim // 2)\n",
|
||||
" sin = sin[:seq_len, :].unsqueeze(0).unsqueeze(0)\n",
|
||||
"\n",
|
||||
" # Apply the rotary transformation\n",
|
||||
|
@ -202,7 +202,7 @@
|
||||
" x2 = x[..., head_dim // 2 :] # Second half\n",
|
||||
"\n",
|
||||
" # Adjust sin and cos shapes\n",
|
||||
" cos = cos[:seq_len, :].unsqueeze(0).unsqueeze(0) # Shape: (1, 1, seq_len, head_dim)\n",
|
||||
" cos = cos[:seq_len, :].unsqueeze(0).unsqueeze(0) # Shape: (1, 1, seq_len, head_dim // 2)\n",
|
||||
" sin = sin[:seq_len, :].unsqueeze(0).unsqueeze(0)\n",
|
||||
"\n",
|
||||
" # Apply the rotary transformation\n",
|
||||
|
@ -226,7 +226,7 @@
|
||||
" x2 = x[..., head_dim // 2 :] # Second half\n",
|
||||
"\n",
|
||||
" # Adjust sin and cos shapes\n",
|
||||
" cos = cos[:seq_len, :].unsqueeze(0).unsqueeze(0) # Shape: (1, 1, seq_len, head_dim)\n",
|
||||
" cos = cos[:seq_len, :].unsqueeze(0).unsqueeze(0) # Shape: (1, 1, seq_len, head_dim // 2)\n",
|
||||
" sin = sin[:seq_len, :].unsqueeze(0).unsqueeze(0)\n",
|
||||
"\n",
|
||||
" # Apply the rotary transformation\n",
|
||||
@ -1201,7 +1201,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.9"
|
||||
"version": "3.10.16"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
@ -292,7 +292,7 @@ def apply_rope(x, cos, sin, offset=0):
|
||||
x2 = x[..., head_dim // 2:] # Second half
|
||||
|
||||
# Adjust sin and cos shapes
|
||||
cos = cos[offset:offset + seq_len, :].unsqueeze(0).unsqueeze(0) # Shape: (1, 1, seq_len, head_dim)
|
||||
cos = cos[offset:offset + seq_len, :].unsqueeze(0).unsqueeze(0) # Shape: (1, 1, seq_len, head_dim // 2)
|
||||
sin = sin[offset:offset + seq_len, :].unsqueeze(0).unsqueeze(0)
|
||||
|
||||
# Apply the rotary transformation
|
||||
|
@ -236,7 +236,7 @@ def apply_rope(x, cos, sin, offset=0):
|
||||
x2 = x[..., head_dim // 2:] # Second half
|
||||
|
||||
# Adjust sin and cos shapes
|
||||
cos = cos[offset:offset + seq_len, :].unsqueeze(0).unsqueeze(0) # Shape: (1, 1, seq_len, head_dim)
|
||||
cos = cos[offset:offset + seq_len, :].unsqueeze(0).unsqueeze(0) # Shape: (1, 1, seq_len, head_dim // 2)
|
||||
sin = sin[offset:offset + seq_len, :].unsqueeze(0).unsqueeze(0)
|
||||
|
||||
# Apply the rotary transformation
|
||||
|
@ -260,7 +260,7 @@ def apply_rope(x, cos, sin):
|
||||
x2 = x[..., head_dim // 2:] # Second half
|
||||
|
||||
# Adjust sin and cos shapes
|
||||
cos = cos[:seq_len, :].unsqueeze(0).unsqueeze(0) # Shape: (1, 1, seq_len, head_dim)
|
||||
cos = cos[:seq_len, :].unsqueeze(0).unsqueeze(0) # Shape: (1, 1, seq_len, head_dim // 2)
|
||||
sin = sin[:seq_len, :].unsqueeze(0).unsqueeze(0)
|
||||
|
||||
# Apply the rotary transformation
|
||||
|
@ -288,7 +288,7 @@ def apply_rope(x, cos, sin):
|
||||
x2 = x[..., head_dim // 2:] # Second half
|
||||
|
||||
# Adjust sin and cos shapes
|
||||
cos = cos[:seq_len, :].unsqueeze(0).unsqueeze(0) # Shape: (1, 1, seq_len, head_dim)
|
||||
cos = cos[:seq_len, :].unsqueeze(0).unsqueeze(0) # Shape: (1, 1, seq_len, head_dim // 2)
|
||||
sin = sin[:seq_len, :].unsqueeze(0).unsqueeze(0)
|
||||
|
||||
# Apply the rotary transformation
|
||||
|
Loading…
x
Reference in New Issue
Block a user