
gittech. site
for different kinds of informations and explorations.
Practise PyTorch in LeetCode Style
Published at
Jan 14, 2025
Main Article
TorchLeet is a curated set of PyTorch practice problems, inspired by LeetCode-style challenges, designed to enhance your skills in deep learning and PyTorch.
Table of Contents
Question Set
🟢Easy
- Implement linear regression (Solution)
- Write a custom Dataset and Dataloader to load from a CSV file (Solution)
- Write a custom activation function (Simple) (Solution)
- Implement Custom Loss Function (Huber Loss) (Solution)
- Implement a Deep Neural Network (Solution)
- Visualize Training Progress with TensorBoard in PyTorch (Solution)
- Save and Load Your PyTorch Model (Solution)
🟡Medium
- Implement an LSTM (Solution)
- Implement a CNN on CIFAR-10 (Solution)
- Implement parameter initialization for a CNN (Solution)
- Implement an RNN (Solution)
- Use
torchvision.transforms
to apply data augmentation (Solution) - Add a benchmark to your PyTorch code (Solution)
- Train an autoencoder for anomaly detection (Solution)
🔴Hard
- Write a custom Autograd function for activation (SILU) (Solution)
- Write a Neural Style Transfer
- Write a Transformer (Solution)
- Write a GAN (Solution)
- Write Sequence-to-Sequence with Attention (Solution)
- Quantize your language model (Solution)
- [Enable distributed training in pytorch (DistributedDataParallel)]
- [Work with Sparse Tensors]
- Implement Mixed Precision Training using torch.cuda.amp (Solution)
- Add GradCam/SHAP to explain the model. (Solution)
What's cool? 🚀
- Diverse Questions: Covers beginner to advanced PyTorch concepts (e.g., tensors, autograd, CNNs, GANs, and more).
- Guided Learning: Includes incomplete code blocks (
...
and#TODO
) for hands-on practice along with Answers
Getting Started
1. Install Dependencies
- Install pytorch: Install pytorch locally
- Some problems need other packages. Install as needed.
2. Structure
<E/M/H><ID>/
: Easy/Medium/Hard along with the question ID.<E/M/H><ID>/qname.ipynb
: The question file with incomplete code blocks.<E/M/H><ID>/qname_SOLN.ipynb
: The corresponding solution file.
3. How to Use
- Navigate to questions/ and pick a problem
- Fill in the missing code blocks
(...)
and address the#TODO
comments. - Test your solution and compare it with the corresponding file in
solutions/
.
Happy Learning! 🚀
Contribution
Feel free to contribute by adding new questions or improving existing ones. Ensure that new problems are well-documented and follow the project structure.
Authors
Chandrahas Aroori 💻 AI/ML Dev |
Caslow Chien 💻 Developer |