- Introduction: Beyond the Two Magical Lines
- Chapter 1: The Linear Forward Step
- Chapter 2: Activation Functions
- Chapter 3: Binary Cross-Entropy
- Chapter 4: Backpropagation
- Chapter 5: Gradient Descent and the First Training Loop
- Chapter 6: Verifying Backpropagation with Gradient Checking
- Chapter 7: Building an Evaluation Dataset
- Chapter 8: Diagnosing Training Problems
- Chapter 9: Mini-Batch Training and Epochs
- Chapter 10: L2 Regularization
- Chapter 11: Organizing the Project
- Chapter 12: Review, Extensions, and Responsible Evaluation
- Chapter 13: Closing Thoughts
- Appendix A: Reproducibility, Cross-Validation, and Next Steps
- Appendix B: A Practical Model-Development Playbook
- Appendix C: Reference Implementation Checklist
- Appendix D: Programming Exercises and Test Assignments
- Appendix E: Parametrized Tests and Advanced Exercises
- Appendix F: Test Fixtures, Markers, and Quality Gates
- Appendix G: Skipping, Expected Failures, and Test Strategy
- Appendix H: Final Checklist, Glossary, and Further Reading
Behind the Black Box: Building Neural Networks From Scratch
Build, Train, Validate, and Understand a Neural Network with Pure Python and NumPy
Stop treating neural networks as a black box.
Build a two-layer binary classifier from scratch with Python and NumPy. Learn the forward pass, binary cross-entropy, backpropagation, gradient descent, mini-batch training, L2 regularization, gradient checking, and leakage-safe evaluation.
This book focuses on understanding—not copying code.
Minimum price
$12.00
$15.00
You pay
Author earns
About
About the Book
Build a Neural Network From Scratch
Most machine-learning tutorials stop after calling model.fit(). This book goes further: it shows you how to build, train, validate, and evaluate a small neural network using only Python and NumPy.
You will implement a two-layer binary classifier from first principles. You will learn how data flows through a network, how predictions become probabilities, how errors become gradients, and how gradients update parameters.
You will build a practical understanding of:
- The linear forward pass
- ReLU and sigmoid activation functions
- Binary cross-entropy
- Numerically stable loss calculation using logits
- Backpropagation and the chain rule
- Gradient descent
- Mini-batch training and epochs
- L2 regularization
- Gradient clipping
- Gradient checking
- Train, validation, and test splits
- Classification metrics
- Leakage-safe model evaluation
- Reproducible machine-learning workflows
This book is for Python developers, students, and aspiring machine-learning engineers who want to understand what happens inside a neural network before relying entirely on high-level frameworks.
You do not need prior deep-learning experience. Basic Python and high-school-level algebra are enough to follow along.
This is not a collection of copied code snippets. Each concept is connected to a clear implementation. You will see how a forward pass produces predictions, how a loss measures mistakes, how backpropagation calculates gradients, and how gradient descent updates parameters.
You will also learn how to evaluate a model honestly. The book distinguishes training performance from generalization, explains why validation data guides model selection, and shows why a test set should be evaluated only after the final configuration has been selected.
Important note: This is an early-access edition. The book is actively being developed and expanded. It focuses on building a strong, honest foundation in neural networks and responsible model evaluation.
Feedback
Bundles
Bundles that include this book
- Pricing
$22.00
Minimum priceBought separately$32.00Suggested price$29.00
- Pricing
$19.99
Minimum priceBought separately$55.98Suggested price$29.99
- Pricing
$15.99
Minimum priceBought separately$42.98Suggested price$19.99
- Pricing
$22.99
Minimum priceBought separately$53.97Suggested price$31.99
Author
About the Author
Ahmed Adawy is an independent author and tech enthusiast passionate about bridging the gap between theoretical science and practical coding. With a focus on applied mathematics, linear algebra, and machine learning, he creates beginner-friendly guides designed to help programmers and students master the core mechanics behind modern AI. His writing breaks down complex academic formulas into clear, actionable Python code.
Contents
Table of Contents
Get the free Community Edition
You can get the free Community Edition in PDF or EPUB just by sharing your name and email address with the author.
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Write and Publish on Leanpub
You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!
Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.
Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.



