mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-05-06 17:49:07 -05:00
Tiny-torch 03-layers have Tensor(, requires_grad=True). but 01-Tensor not #479
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @wz1114841863 on GitHub (Jan 13, 2026).
layers.ipynb specifies requires_grad=True when initializing the Tensor, but this initialization parameter is not specified when constructing the Tensor class in tensor.ipynb. Therefore, an error occurs during execution. Is this behavior as expected?
@wz1114841863 commented on GitHub (Jan 13, 2026):
I manually modified the Tensor definition in

tinytorch/core/tensor.pyto ensure the tests in03-layersrun correctly in Jupyter. However, when submitting withtito module complete 03, I encountered the following error. I did not modify any code in Jupyter—only read and understood it—so I'm unsure what caused this issue, especially since all unit tests passed.@profvjreddi commented on GitHub (Jan 13, 2026):
This is the same issue we just fixed in PR #1101.
Module 03 was incorrectly passing requires_grad=True to the Tensor constructor, but requires_grad isn't introduced until Module 06 via monkey-patching. I removed the premature requires_grad=True from the Linear layer so students can complete Module 03 without needing autograd.
I just fixed in https://github.com/harvard-edge/cs249r_book/commit/a36340690. I can't believe this slipped through my tests 😮💨
If you pull the latest
devbranch, this should work now. Thanks for reporting!@profvjreddi commented on GitHub (Jan 23, 2026):
v0.1.4 is now released with this fix! See #1112 for update instructions.