mirror of
https://github.com/MLSysBook/TinyTorch.git
synced 2026-05-31 19:11:34 -05:00
🧪 Add missing test function calls and fix name mismatches in 09_autograd module
- Added test_unit_variable_class() call after function definition - Added test_unit_add_operation() call after function definition - Added test_unit_multiply_operation() call after function definition - Added test_unit_subtract_operation() call after function definition - Added test_unit_chain_rule() call after function definition - Added test_module_neural_network_training() call after function definition - Fixed function name mismatches in existing if __name__ == '__main__' calls Ensures all test functions are executed when cells run, providing immediate feedback to students.
This commit is contained in:
@@ -350,9 +350,12 @@ def test_unit_variable_class():
|
||||
print(f"✅ Data access and properties working")
|
||||
print(f"✅ Gradient management working")
|
||||
|
||||
# Run the test
|
||||
test_unit_variable_class()
|
||||
|
||||
# Run inline tests when module is executed directly
|
||||
if __name__ == "__main__":
|
||||
test_variable_class()
|
||||
test_unit_variable_class()
|
||||
|
||||
# %% [markdown]
|
||||
"""
|
||||
@@ -493,6 +496,9 @@ def test_unit_add_operation():
|
||||
print(f"✅ Backward pass computing correct gradients")
|
||||
print(f"✅ Scalar addition working correctly")
|
||||
|
||||
# Run the test
|
||||
test_unit_add_operation()
|
||||
|
||||
# Run inline tests when module is executed directly
|
||||
if __name__ == "__main__":
|
||||
test_add_operation()
|
||||
@@ -627,9 +633,12 @@ def test_unit_multiply_operation():
|
||||
print(f"✅ Backward pass implementing product rule correctly")
|
||||
print(f"✅ Scalar multiplication working correctly")
|
||||
|
||||
# Run the test
|
||||
test_unit_multiply_operation()
|
||||
|
||||
# Run inline tests when module is executed directly
|
||||
if __name__ == "__main__":
|
||||
test_multiply_operation()
|
||||
test_unit_multiply_operation()
|
||||
|
||||
# %% nbgrader={"grade": false, "grade_id": "subtract-operation", "locked": false, "schema_version": 3, "solution": true, "task": false}
|
||||
#| export
|
||||
@@ -725,9 +734,12 @@ def test_unit_subtract_operation():
|
||||
print(f"✅ Backward pass implementing subtraction rule correctly")
|
||||
print(f"✅ Scalar subtraction working correctly")
|
||||
|
||||
# Run the test
|
||||
test_unit_subtract_operation()
|
||||
|
||||
# Run inline tests when module is executed directly
|
||||
if __name__ == "__main__":
|
||||
test_subtract_operation()
|
||||
test_unit_subtract_operation()
|
||||
|
||||
# %% [markdown]
|
||||
"""
|
||||
@@ -810,9 +822,12 @@ def test_unit_chain_rule():
|
||||
print(f"✅ Automatic gradient computation working correctly")
|
||||
print(f"✅ Chain rule implemented correctly")
|
||||
|
||||
# Run the test
|
||||
test_unit_chain_rule()
|
||||
|
||||
# Run inline tests when module is executed directly
|
||||
if __name__ == "__main__":
|
||||
test_chain_rule()
|
||||
test_unit_chain_rule()
|
||||
|
||||
# %% [markdown]
|
||||
"""
|
||||
@@ -926,6 +941,9 @@ def test_module_neural_network_training():
|
||||
print(f"✅ Autograd enables automatic training")
|
||||
print(f"✅ Ready for complex neural network architectures!")
|
||||
|
||||
# Run the test
|
||||
test_module_neural_network_training()
|
||||
|
||||
# %% [markdown]
|
||||
"""
|
||||
## 🧪 Module Testing
|
||||
|
||||
Reference in New Issue
Block a user