Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR implements the Muon optimizer using pure NumPy, completing the neural network optimizers module for the repository.
Muon is a cutting-edge optimizer specifically designed for hidden layer weight matrices in neural networks, using Newton-Schulz matrix orthogonalization iterations for improved convergence and computational efficiency.
This PR addresses part of issue #13662 - Add neural network optimizers module to enhance training capabilities
What does this PR do?
Implementation Details
Why Muon?
Muon represents state-of-the-art optimizer research and offers several advantages:
Features
✅ Complete docstrings with parameter descriptions
✅ Type hints for all function parameters and return values
✅ Doctests for correctness validation
✅ Usage example demonstrating optimizer on matrix optimization
✅ PEP8 compliant code formatting
✅ Newton-Schulz orthogonalization implementation
✅ Configurable hyperparameters (learning rate, momentum, iteration steps)
✅ Pure NumPy - no external deep learning frameworks
Testing
All doctests pass:
Linting passes:
Example output demonstrates proper optimization behavior on matrix parameters.
References
Relation to Issue #13662
This PR completes the optimizer sequence outlined in #13662:
With this PR, the neural network optimizers module is now complete with 6 fundamental optimizers covering classical to cutting-edge optimization techniques.
Use Cases
Muon is particularly effective for:
Checklist
Summary
This PR marks the completion of the neural network optimizers module, providing educators and learners with a comprehensive collection of optimization algorithms from fundamental SGD to cutting-edge Muon. The module now serves as a complete educational resource for understanding neural network training optimization.
This PR along with the following PRs collectively fixes issue #13662:
Related PRs:
Fixes #13662 (This PR completes the neural network optimizers module)