Commit Graph

10 Commits

Author SHA1 Message Date
Vijay Janapa Reddi
00019408b0 Add tito verify command and expand package exports
- Add tito verify command for setup validation and community registration
- Fix broken Dense import in tinytorch/__init__.py (class does not exist)
- Clean up layers.py __all__ to remove non-existent Dense and internal constants
- Add commonly used components to top-level exports:
  - AvgPool2d, BatchNorm2d (spatial operations)
  - RandomHorizontalFlip, RandomCrop, Compose (data augmentation)
- Total exports now 41 (was 35)
2025-12-02 15:56:32 -05:00
Vijay Janapa Reddi
bd7fcb2177 Release preparation: fix package exports, tests, and documentation
Package exports:
- Fix tinytorch/__init__.py to export all required components for milestones
- Add Dense as alias for Linear for compatibility
- Add loss functions (MSELoss, CrossEntropyLoss, BinaryCrossEntropyLoss)
- Export spatial operations, data loaders, and transformer components

Test infrastructure:
- Create tests/conftest.py to handle path setup
- Create tests/test_utils.py with shared test utilities
- Rename test_progressive_integration.py files to include module number
- Fix syntax errors in test files (spaces in class names)
- Remove stale test file referencing non-existent modules

Documentation:
- Update README.md with correct milestone file names
- Fix milestone requirements to match actual module dependencies

Export system:
- Run tito export --all to regenerate package from source modules
- Ensure all 20 modules are properly exported
2025-12-02 14:19:56 -05:00
Vijay Janapa Reddi
c10b3b9f12 Add quiet parameter to enable_autograd() for CLI tools
- Add quiet=False parameter to enable_autograd()
- Suppress print statements when quiet=True
- Check TINYTORCH_QUIET env var on module import
- Allows CLI tools to import tinytorch silently
- Students still see helpful messages in notebooks
2025-11-26 18:11:00 +01:00
Vijay Janapa Reddi
5ae68dd4b4 Fix gradient propagation: enable autograd and patch activations/losses
CRITICAL FIX: Gradients now flow through entire training stack!

Changes:
1. Enable autograd in __init__.py - patches Tensor operations on import
2. Extend enable_autograd() to patch Sigmoid and BCE forward methods
3. Fix gradient accumulation to handle broadcasting (bias gradients)
4. Fix optimizer.step() - param.grad is numpy array, not Tensor.data
5. Add debug_gradients.py for systematic gradient flow testing

Architecture:
- Clean patching pattern - all gradient tracking in enable_autograd()
- Activations/losses remain simple (Module 02/04)
- Autograd (Module 05) upgrades them with gradient tracking
- Pedagogically sound: separation of concerns

Results:
 All 6 debug tests pass
 Perceptron learns: 50% → 93% accuracy
 Loss decreases: 0.79 → 0.36
 Weights update correctly through SGD
2025-09-30 13:51:30 -04:00
Vijay Janapa Reddi
c9f53a6b69 Use clean top-level imports from tinytorch
- Updated tinytorch/__init__.py to export all common components at top level
- Changed milestone imports from 'tinytorch.core.*' to 'tinytorch'
- Students now use: from tinytorch import Tensor, Linear, Sigmoid, SGD
- Cleaner API that respects module boundaries
- Added enable_autograd() that enhances operations without modifying source modules

STILL TODO: Fix gradient flow - training not learning yet
2025-09-30 13:29:22 -04:00
Vijay Janapa Reddi
8be87d0add Fix nbdev export system across all 20 modules
PROBLEM:
- nbdev requires #| export directive on EACH cell to export when using # %% markers
- Cell markers inside class definitions split classes across multiple cells
- Only partial classes were being exported to tinytorch package
- Missing matmul, arithmetic operations, and activation classes in exports

SOLUTION:
1. Removed # %% cell markers INSIDE class definitions (kept classes as single units)
2. Added #| export to imports cell at top of each module
3. Added #| export before each exportable class definition in all 20 modules
4. Added __call__ method to Sigmoid for functional usage
5. Fixed numpy import (moved to module level from __init__)

MODULES FIXED:
- 01_tensor: Tensor class with all operations (matmul, arithmetic, shape ops)
- 02_activations: Sigmoid, ReLU, Tanh, GELU, Softmax classes
- 03_layers: Linear, Dropout classes
- 04_losses: MSELoss, CrossEntropyLoss, BinaryCrossEntropyLoss classes
- 05_autograd: Function, AddBackward, MulBackward, MatmulBackward, SumBackward
- 06_optimizers: Optimizer, SGD, Adam, AdamW classes
- 07_training: CosineSchedule, Trainer classes
- 08_dataloader: Dataset, TensorDataset, DataLoader classes
- 09_spatial: Conv2d, MaxPool2d, AvgPool2d, SimpleCNN classes
- 10-20: All exportable classes in remaining modules

TESTING:
- Test functions use 'if __name__ == "__main__"' guards
- Tests run in notebooks but NOT on import
- Rosenblatt Perceptron milestone working perfectly

RESULT:
 All 20 modules export correctly
 Perceptron (1957) milestone functional
 Clean separation: development (modules/source) vs package (tinytorch)
2025-09-30 11:21:04 -04:00
Vijay Janapa Reddi
c955437078 Organize package with nn and optim modules
Stage 5 of TinyTorch API simplification:
- Created tinytorch.nn package with PyTorch-compatible interface
- Added Module base class in nn.modules for automatic parameter registration
- Added functional module with relu, flatten, max_pool2d operations
- Created tinytorch.optim package exposing Adam and SGD optimizers
- Updated main __init__.py to export nn and optim modules
- Linear and Conv2d now available through clean nn interface

Students can now write PyTorch-like code:
import tinytorch.nn as nn
import tinytorch.nn.functional as F
model = nn.Linear(784, 10)
x = F.relu(model(x))
2025-09-23 08:10:47 -04:00
Vijay Janapa Reddi
83fb269d9f Complete migration from modules/ to assignments/source/ structure
- Migrated all Python source files to assignments/source/ structure
- Updated nbdev configuration to use assignments/source as nbs_path
- Updated all tito commands (nbgrader, export, test) to use new structure
- Fixed hardcoded paths in Python files and documentation
- Updated config.py to use assignments/source instead of modules
- Fixed test command to use correct file naming (short names vs full module names)
- Regenerated all notebook files with clean metadata
- Verified complete workflow: Python source → NBGrader → nbdev export → testing

All systems now working: NBGrader (14 source assignments, 1 released), nbdev export (7 generated files), and pytest integration.

The modules/ directory has been retired and replaced with standard NBGrader structure.
2025-07-12 12:06:56 -04:00
Vijay Janapa Reddi
5fc55f8cbe Been refactoring the structure, got setup working 2025-07-10 11:13:45 -04:00
Vijay Janapa Reddi
e587ee0b36 Initializes TinyTorch project structure and setup
Sets up the foundational project structure for the TinyTorch ML system, including the CLI entry point, project directories, and setup scripts.

This commit introduces the `tito` CLI for project management, testing, and information display.
It also includes setup scripts to automate environment creation and verification, along with initial documentation.
2025-07-09 00:46:26 -04:00