From ecf7e9f6a2a0b7e2524cab4477978667e913109d Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Fri, 28 Apr 2023 21:48:51 -0400 Subject: [PATCH 1/3] cmp: adds comparison of shapes Output "shape ok: True/False" if the manual gradient's shape is the same as the autograd gradient shape --- lectures/makemore/makemore_part4_backprop.ipynb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lectures/makemore/makemore_part4_backprop.ipynb b/lectures/makemore/makemore_part4_backprop.ipynb index 11b800a8..b9498cbd 100644 --- a/lectures/makemore/makemore_part4_backprop.ipynb +++ b/lectures/makemore/makemore_part4_backprop.ipynb @@ -144,7 +144,8 @@ " ex = torch.all(dt == t.grad).item()\n", " app = torch.allclose(dt, t.grad)\n", " maxdiff = (dt - t.grad).abs().max().item()\n", - " print(f'{s:15s} | exact: {str(ex):5s} | approximate: {str(app):5s} | maxdiff: {maxdiff}')" + " shape_ok = dt.shape == t.shape + " print(f'{s:15s} | shape ok: {shape_ok} | exact: {str(ex):5s} | approximate: {str(app):5s} | maxdiff: {maxdiff}')" ] }, { From 0ece6c7cbfc1fff5f7f5f7189cf0573ca88939f5 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Fri, 28 Apr 2023 21:51:25 -0400 Subject: [PATCH 2/3] Fixes invalid notebook error --- lectures/makemore/makemore_part4_backprop.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lectures/makemore/makemore_part4_backprop.ipynb b/lectures/makemore/makemore_part4_backprop.ipynb index b9498cbd..6b78f40f 100644 --- a/lectures/makemore/makemore_part4_backprop.ipynb +++ b/lectures/makemore/makemore_part4_backprop.ipynb @@ -144,7 +144,7 @@ " ex = torch.all(dt == t.grad).item()\n", " app = torch.allclose(dt, t.grad)\n", " maxdiff = (dt - t.grad).abs().max().item()\n", - " shape_ok = dt.shape == t.shape + " shape_ok = dt.shape == t.shape\n", " print(f'{s:15s} | shape ok: {shape_ok} | exact: {str(ex):5s} | approximate: {str(app):5s} | maxdiff: {maxdiff}')" ] }, From cc6e28adcc532b42b4a695889f9c514e3272ee85 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sat, 29 Apr 2023 11:58:17 -0400 Subject: [PATCH 3/3] text output tweak Moved the correct shape output to the end of the line. --- lectures/makemore/makemore_part4_backprop.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lectures/makemore/makemore_part4_backprop.ipynb b/lectures/makemore/makemore_part4_backprop.ipynb index 6b78f40f..6e721113 100644 --- a/lectures/makemore/makemore_part4_backprop.ipynb +++ b/lectures/makemore/makemore_part4_backprop.ipynb @@ -145,7 +145,7 @@ " app = torch.allclose(dt, t.grad)\n", " maxdiff = (dt - t.grad).abs().max().item()\n", " shape_ok = dt.shape == t.shape\n", - " print(f'{s:15s} | shape ok: {shape_ok} | exact: {str(ex):5s} | approximate: {str(app):5s} | maxdiff: {maxdiff}')" + " print(f'{s:15s} | exact: {str(ex):5s} | approximate: {str(app):5s} | maxdiff: {maxdiff} | shape is correct: {shape_ok}')" ] }, {