# srush/tensor-puzzles

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/srush-tensor-puzzles).**

4,162 stars · 378 forks · Jupyter Notebook · MIT

## Links

- GitHub: https://github.com/srush/Tensor-Puzzles
- awesome-repositories: https://awesome-repositories.com/repository/srush-tensor-puzzles.md

## Topics

`machine-learning` `puzzle` `torch`

## Description

Tensor-Puzzles is an educational exercise suite and numerical computing tutorial designed for mastering tensor operations and broadcasting rules within PyTorch. It functions as an implementation trainer where users practice transitioning mathematical formulas into code by reimplementing deep learning mathematical primitives.

The project utilizes a constraint-based exercise suite that restricts available library calls to force the use of specific tensor primitives. These challenges are structured as sequential puzzles that require users to solve tasks using a modular implementation pattern, where complex functions are broken down into simpler dependent operations.

Correctness is ensured through a PyTorch-integrated execution environment that uses reference-implementation validation and numerical-tolerance checks. The system verifies that user-defined outputs match reference results and adhere to standard multidimensional array broadcasting rules.

## Tags

### Artificial Intelligence & ML

- [Tensor Broadcasting](https://awesome-repositories.com/f/artificial-intelligence-ml/tensor-broadcasting.md) — Provides a mechanism for validating that multi-dimensional arrays align according to standard tensor broadcasting rules.
- [Runtime Evaluation Environments](https://awesome-repositories.com/f/artificial-intelligence-ml/deep-learning-frameworks/pytorch-based-frameworks/runtime-evaluation-environments.md) — Provides an execution environment that runs user code within a live PyTorch session for validation.
- [PyTorch Tensor Operations](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-optimization-and-inference/hardware-and-acceleration/tensor-computing-libraries/pytorch-tensor-operations.md) — Integrates with PyTorch to execute tensor operations and validate runtime shapes and types.

### Education & Learning Resources

- [PyTorch Code Exercises](https://awesome-repositories.com/f/education-learning-resources/deep-learning-education/deep-learning-platforms/pytorch-deep-learning-examples/pytorch-code-exercises.md) — Offers practical exercises and constrained challenges for learning multi-dimensional array manipulation in PyTorch.
- [Machine Learning Mathematics](https://awesome-repositories.com/f/education-learning-resources/machine-learning-curricula/machine-learning-mathematics.md) — Teaches the fundamental mathematical operations and logic underlying neural network layers.
- [Automated Exercise Suites](https://awesome-repositories.com/f/education-learning-resources/programming-exercises/automated-exercise-suites.md) — Provides a series of coding tasks bundled with automated verification for tensor operation implementation.
- [Implementation Trainers](https://awesome-repositories.com/f/education-learning-resources/deep-learning-education/deep-learning-platforms/pytorch-deep-learning-examples/pytorch-code-exercises/implementation-trainers.md) — Trains users to transition from mathematical formulas to efficient PyTorch code through verified exercises.
- [Progressive Learning Paths](https://awesome-repositories.com/f/education-learning-resources/exercise-solutions/progressive-learning-paths.md) — Structures tensor manipulation tasks as a series of progressive puzzles where solutions build on previous concepts.
- [Programming Course Materials](https://awesome-repositories.com/f/education-learning-resources/programming-course-materials.md) — Offers structured sets of interactive lessons for reimplementing deep learning mathematical primitives.

### Software Engineering & Architecture

- [API Call Restrictions](https://awesome-repositories.com/f/software-engineering-architecture/constraint-based-logic-engines/api-call-restrictions.md) — Restricts available library calls to force the use of specific tensor primitives during exercises.

### Testing & Quality Assurance

- [Reference Implementation Validation](https://awesome-repositories.com/f/testing-quality-assurance/reference-implementation-validation.md) — Evaluates user submissions against a hidden gold-standard implementation to ensure mathematical equivalence.
- [Runtime Shape Verification](https://awesome-repositories.com/f/testing-quality-assurance/array-shape-validation/runtime-shape-verification.md) — Provides runtime verification to ensure tensor dimensions adhere to broadcasting alignment rules.
- [Numerical Tolerance Checks](https://awesome-repositories.com/f/testing-quality-assurance/numerical-tolerance-checks.md) — Implements a test runner that verifies tensor output correctness using numerical tolerance epsilon checks.

### Scientific & Mathematical Computing

- [Precision-Tolerant Comparisons](https://awesome-repositories.com/f/scientific-mathematical-computing/floating-point-arithmetic/precision-tolerant-comparisons.md) — Uses epsilon-based precision-tolerant comparisons to handle floating point rounding errors in tensor results.
- [Interactive Tutorials](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/mathematical-libraries-and-utilities/mathematics/numerical-computing/interactive-tutorials.md) — Serves as a guided set of challenges for understanding tensor broadcasting and linear algebra fundamentals.
