TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: From-Scratch ML Library (trains models from CNNs to a toy GPT-2)

1 pointsby megadragon93 months ago
Hi HN,<p>I built a machine learning library entirely from scratch using only Python and NumPy. I then used it to train a range of models—from classical CNNs, ResNets, RNNs, and LSTMs to modern Transformers and even a toy GPT-2. The motivation came from my curiosity about how to build deep learning models from scratch, like literally from mathematical formulas. I built this project not to replace production-ready libraries like PyTorch or TensorFlow, but to strip away the abstractions and reveal the underlying mathematics of machine learning.<p>Key points:<p>- Everything is derived in code — no opaque black boxes.<p>- API mirrors PyTorch so you can pick it up quickly.<p>- You can train CNNs, RNNs, Transformers, and even GPT models.<p>- Designed more for learning&#x2F;debugging than raw performance.<p>What’s different here?<p>While there are many powerful ML libraries available (TensorFlow, PyTorch, Scikit-learn, etc.), they often hide the underlying math behind layers of abstraction. I believe that to truly master these tools, you first need to understand how they work from the ground up. This project explicitly derives all the mathematical and calculus operations in the code, making it a hands-on resource for deepening the understanding of neural networks and library building :)<p>Check it out:<p>- Github Repository: <a href="https:&#x2F;&#x2F;github.com&#x2F;workofart&#x2F;ml-by-hand">https:&#x2F;&#x2F;github.com&#x2F;workofart&#x2F;ml-by-hand</a><p>- API Documentation: <a href="https:&#x2F;&#x2F;ml-by-hand.readthedocs.io&#x2F;en&#x2F;latest&#x2F;" rel="nofollow">https:&#x2F;&#x2F;ml-by-hand.readthedocs.io&#x2F;en&#x2F;latest&#x2F;</a><p>- Examples: Explore models like GPT-2, CNNs, Transformers, and LSTMs in the examples&#x2F; folder: <a href="https:&#x2F;&#x2F;github.com&#x2F;workofart&#x2F;ml-by-hand&#x2F;tree&#x2F;main&#x2F;examples">https:&#x2F;&#x2F;github.com&#x2F;workofart&#x2F;ml-by-hand&#x2F;tree&#x2F;main&#x2F;examples</a><p>- Blog Post: Read about the project’s motivation, design, and challenges at <a href="https:&#x2F;&#x2F;www.henrypan.com&#x2F;blog&#x2F;2025-02-06-ml-by-hand&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.henrypan.com&#x2F;blog&#x2F;2025-02-06-ml-by-hand&#x2F;</a><p>I’d love to hear any thoughts, questions, or suggestions — thanks for checking it out!

no comments

no comments