Tensors - Extending Autodifferentiation to Multidimensional Arrays
Module 2 introduces Tensors - multidimensional arrays that extend the scalar autodifferentiation system from Module 1. While the scalar system is correct, it's inefficient due to Python overhead. Tensors solve this by grouping operations together and enabling faster implementations.
See installation.md for detailed setup instructions.
# Install dependencies
pip install -e ".[dev,extra]"
# Sync files from Module 1
python sync_previous_module.py ../Module-1 .
# Verify installation
python -c "import minitorch; print('Success!')"
# Run tests
pytest -m task2_1 # Tensor data and indexing
pytest -m task2_2 # Tensor broadcasting
pytest -m task2_3 # Tensor operations
pytest -m task2_4 # Tensor autodifferentiation
# Train tensor-based model
python project/run_tensor.pyFile to Edit: minitorch/tensor_data.py
File to Edit: minitorch/tensor_data.py
Files to Edit: minitorch/tensor_ops.py, minitorch/tensor_functions.py
Files to Edit: minitorch/tensor_functions.py
File to Edit: project/run_tensor.py
Requirements:
- Train on the first four datasets and record results in README
- Record time per epoch for performance comparison
- Should match functionality of
project/run_scalar.pybut use tensor operations - To run streamlit, use:
streamlit run project/app.py -- 2See testing.md for detailed testing instructions.
This assignment requires the following files from Module 1. You can get these by running:
python sync_previous_module.py ../Module-1 .The files that will be synced are:
minitorch/operators.pyminitorch/module.pyminitorch/autodiff.pyminitorch/scalar.pyproject/run_manual.pyproject/run_scalar.py