Skip to content

Commit

Permalink
fixes karpathy#59
Browse files Browse the repository at this point in the history
Fixes karpathy#59: Corrected the shape of `dbnmeani`, which should be [1, 64] instead of [64].
  • Loading branch information
conscell authored Dec 27, 2024
1 parent 73c3fcc commit 9ae6af2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lectures/makemore/makemore_part4_backprop.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@
"dbndiff2 = (1.0/(n-1))*torch.ones_like(bndiff2) * dbnvar\n",
"dbndiff += (2*bndiff) * dbndiff2\n",
"dhprebn = dbndiff.clone()\n",
"dbnmeani = (-dbndiff).sum(0)\n",
"dbnmeani = (-dbndiff).sum(0, keepdim=True)\n",
"dhprebn += 1.0/n * (torch.ones_like(hprebn) * dbnmeani)\n",
"dembcat = dhprebn @ W1.T\n",
"dW1 = embcat.T @ dhprebn\n",
Expand Down Expand Up @@ -598,7 +598,7 @@
"# dbndiff2 = (1.0/(n-1))*torch.ones_like(bndiff2) * dbnvar\n",
"# dbndiff += (2*bndiff) * dbndiff2\n",
"# dhprebn = dbndiff.clone()\n",
"# dbnmeani = (-dbndiff).sum(0)\n",
"# dbnmeani = (-dbndiff).sum(0, keepdim=True)\n",
"# dhprebn += 1.0/n * (torch.ones_like(hprebn) * dbnmeani)\n",
"\n",
"# calculate dhprebn given dhpreact (i.e. backprop through the batchnorm)\n",
Expand Down

0 comments on commit 9ae6af2

Please sign in to comment.