vanillanets 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Umar Balak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,23 @@
1
+ # Include essential files
2
+ include README.md
3
+ include LICENSE
4
+ include requirements.txt
5
+ include MANIFEST.in
6
+
7
+ # Include examples (for reference, not installed)
8
+ recursive-include examples *.py
9
+
10
+ # Exclude tests from distribution
11
+ exclude tests
12
+ recursive-exclude tests *
13
+
14
+ # Exclude development/build artifacts
15
+ exclude .gitignore
16
+ exclude .github
17
+ exclude .git
18
+ exclude .pytest_cache
19
+ exclude build
20
+ exclude dist
21
+ exclude *.egg-info
22
+ exclude .venv
23
+ exclude venv
@@ -0,0 +1,383 @@
1
+ Metadata-Version: 2.4
2
+ Name: vanillanets
3
+ Version: 1.0.0
4
+ Summary: A transparent, NumPy-only neural network library for learning and experimentation.
5
+ Home-page: https://github.com/UmarBalak/vanillanets
6
+ Author: Umar Balak
7
+ Author-email: Umar Balak <umarbalak35@gmail.com>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/UmarBalak/vanillanets
10
+ Project-URL: Documentation, https://github.com/UmarBalak/vanillanets#readme
11
+ Project-URL: Repository, https://github.com/UmarBalak/vanillanets
12
+ Project-URL: Bug Tracker, https://github.com/UmarBalak/vanillanets/issues
13
+ Keywords: neural-network,deep-learning,machine-learning,numpy,education,from-scratch
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Education
17
+ Classifier: Intended Audience :: Science/Research
18
+ Classifier: License :: OSI Approved :: MIT License
19
+ Classifier: Natural Language :: English
20
+ Classifier: Operating System :: OS Independent
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3.8
23
+ Classifier: Programming Language :: Python :: 3.9
24
+ Classifier: Programming Language :: Python :: 3.10
25
+ Classifier: Programming Language :: Python :: 3.11
26
+ Classifier: Programming Language :: Python :: 3.12
27
+ Classifier: Topic :: Education
28
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
29
+ Requires-Python: >=3.8
30
+ Description-Content-Type: text/markdown
31
+ License-File: LICENSE
32
+ Requires-Dist: numpy>=2.3.3
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=7.0; extra == "dev"
35
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
36
+ Dynamic: author
37
+ Dynamic: home-page
38
+ Dynamic: license-file
39
+ Dynamic: requires-python
40
+
41
+ # VanillaNets v1.0.0
42
+
43
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8%2B-blue)](https://www.python.org/downloads/)
44
+ [![NumPy](https://img.shields.io/badge/dependency-numpy%202.3.3%2B-green)](https://numpy.org/)
45
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
46
+ [![Status: Production Ready ✓](https://img.shields.io/badge/status-production%20ready-success)]()
47
+
48
+ **A transparent, NumPy-only neural network library designed for learning and experimentation.**
49
+
50
+ VanillaNets is a from-scratch implementation of core neural network components using only Python and NumPy. Every component is written explicitly with clarity prioritized over convenience, making the entire system transparent, easy to inspect, and perfect for understanding how neural networks operate under the hood.
51
+
52
+ Whether you're a student learning fundamentals, a researcher prototyping new ideas, or an educator building curriculum, VanillaNets provides a crystal-clear window into neural network mechanics without framework abstractions.
53
+
54
+ ---
55
+
56
+ ## Features
57
+
58
+ ### Core Architecture
59
+ * **Dense Layers** - Fully connected layers with efficient forward and backward passes
60
+ * **Advanced Weight Initialization** - He, Xavier (Glorot), normal and uniform distributions for optimized training
61
+ * **Flexible Bias Initialization** - Zeros or small positive constants to reduce dead units
62
+
63
+ ### Activation Functions (with derivatives)
64
+ * Linear, ReLU & LeakyReLU
65
+ * Tanh & Sigmoid
66
+ * Softmax (with fused Softmax+CrossEntropy backward pass optimization)
67
+
68
+ ### Loss Functions
69
+ * Binary Cross-Entropy (for binary classification)
70
+ * Categorical Cross-Entropy (for multiclass classification)
71
+ * Sparse Categorical Cross-Entropy (for integer-encoded labels)
72
+ * Mean Squared Error (for regression)
73
+
74
+ ### Optimizers
75
+ * **SGD** - Stochastic Gradient Descent with momentum and learning rate decay
76
+ * **Adam** - Adaptive Moment Estimation with adaptive learning rates per parameter
77
+
78
+ ### Metrics & Evaluation
79
+ * **Classification:** Accuracy, Precision, Recall, F1 Score, Confusion Matrix
80
+ * **Regression:** R² Score, Mean Absolute Error (MAE), Root Mean Squared Error (RMSE)
81
+
82
+ ### Model API
83
+ * Sequential model building (`model.add()`)
84
+ * Flexible metrics interface (single metric or multiple metrics as dict/list)
85
+ * Training with `fit()` and optional validation data
86
+ * Inference with `predict()`
87
+ * Batch evaluation with `evaluate()`
88
+
89
+ ### Performance Optimizations
90
+ * Fused Softmax + Categorical Cross-Entropy backward pass (faster training)
91
+ * Efficient NumPy vectorization throughout
92
+ * Memory-conscious layer implementations
93
+
94
+ ---
95
+
96
+ ## Installation
97
+
98
+ ### From PyPI (Recommended)
99
+
100
+ Install directly from PyPI:
101
+
102
+ ```bash
103
+ pip install vanillanets
104
+ ```
105
+
106
+ ### From Source
107
+
108
+ Clone the repository and install in development mode:
109
+
110
+ ```bash
111
+ git clone https://github.com/UmarBalak/vanillanets.git
112
+ cd vanillanets
113
+ pip install -e .
114
+ ```
115
+
116
+ Or install with development dependencies:
117
+
118
+ ```bash
119
+ pip install -e ".[dev]"
120
+ ```
121
+
122
+ ### Requirements
123
+
124
+ - **Python:** 3.8 or higher
125
+ - **NumPy:** 2.3.3+ (for efficient numerical computation)
126
+
127
+ ### Verify Installation
128
+
129
+ ```python
130
+ import vanillanets
131
+ print(f"VanillaNets {vanillanets.__version__} installed successfully!")
132
+
133
+ # Import core components
134
+ from vanillanets import Model, DenseLayer
135
+ from vanillanets.activations import ReLU, Sigmoid
136
+ from vanillanets.losses import BinaryCrossEntropy
137
+ from vanillanets.optimizers import Optimizer_Adam
138
+ from vanillanets.metrics import Accuracy
139
+
140
+ print("✓ All modules imported successfully!")
141
+ ```
142
+
143
+ ---
144
+
145
+ ## Quick Start
146
+
147
+ ### Example 1: Binary Classification
148
+
149
+ ```python
150
+ from vanillanets import Model, DenseLayer, Optimizer_Adam
151
+ from vanillanets.activations import ReLU, Sigmoid
152
+ from vanillanets.losses import BinaryCrossEntropy
153
+ from vanillanets.metrics import Accuracy
154
+
155
+ # Build model
156
+ model = Model()
157
+ model.add(DenseLayer(30, 64))
158
+ model.add(ReLU())
159
+ model.add(DenseLayer(64, 1))
160
+ model.add(Sigmoid())
161
+
162
+ # Compile with loss, optimizer, and metrics
163
+ model.set(
164
+ loss=BinaryCrossEntropy(),
165
+ optimizer=Optimizer_Adam(learning_rate=0.01),
166
+ metrics={'accuracy': Accuracy()}
167
+ )
168
+ model.finalize()
169
+
170
+ # Train the model
171
+ model.fit(X_train, y_train, epochs=100, print_every=10,
172
+ validation_data=(X_val, y_val))
173
+
174
+ # Evaluate on test set
175
+ loss, metrics = model.evaluate(X_test, y_test)
176
+ print(f"Test Loss: {loss:.4f}, Accuracy: {metrics['accuracy']:.4f}")
177
+
178
+ # Make predictions
179
+ predictions = model.predict(X_new)
180
+ ```
181
+
182
+ ### Example 2: Multiclass Classification
183
+
184
+ ```python
185
+ from vanillanets import Model, DenseLayer, Optimizer_Adam
186
+ from vanillanets.activations import ReLU, Softmax
187
+ from vanillanets.losses import CategoricalCrossEntropy
188
+ from vanillanets.metrics import Accuracy
189
+
190
+ # Build model
191
+ model = Model()
192
+ model.add(DenseLayer(784, 128))
193
+ model.add(ReLU())
194
+ model.add(DenseLayer(128, 64))
195
+ model.add(ReLU())
196
+ model.add(DenseLayer(64, 10))
197
+ model.add(Softmax())
198
+
199
+ # Compile
200
+ model.set(
201
+ loss=CategoricalCrossEntropy(),
202
+ optimizer=Optimizer_Adam(learning_rate=0.05),
203
+ metrics={'accuracy': Accuracy()}
204
+ )
205
+ model.finalize()
206
+
207
+ # Train
208
+ model.fit(X_train, y_train, epochs=50, print_every=5)
209
+ ```
210
+
211
+ ### Example 3: Regression
212
+
213
+ ```python
214
+ from vanillanets import Model, DenseLayer, Optimizer_Adam
215
+ from vanillanets.activations import Linear, ReLU
216
+ from vanillanets.losses import MeanSquaredError
217
+ from vanillanets.metrics import RMSE, MAE
218
+
219
+ # Build model
220
+ model = Model()
221
+ model.add(DenseLayer(8, 64))
222
+ model.add(ReLU())
223
+ model.add(DenseLayer(64, 1))
224
+ model.add(Linear())
225
+
226
+ # Compile with multiple metrics
227
+ model.set(
228
+ loss=MeanSquaredError(),
229
+ optimizer=Optimizer_Adam(learning_rate=0.01),
230
+ metrics={'rmse': RMSE(), 'mae': MAE()}
231
+ )
232
+ model.finalize()
233
+
234
+ # Train and evaluate
235
+ model.fit(X_train, y_train, epochs=100, validation_data=(X_val, y_val))
236
+ loss, metrics = model.evaluate(X_test, y_test)
237
+ print(f"Test RMSE: {metrics['rmse']:.4f}, MAE: {metrics['mae']:.4f}")
238
+ ```
239
+
240
+ ---
241
+
242
+ ## Examples
243
+
244
+ Full working examples included:
245
+ * `binary_classification.py` - Breast cancer classification
246
+ * `multiclass_classification.py` - Handwritten digit recognition
247
+ * `regression.py` - California housing price prediction
248
+
249
+ Run any example:
250
+ ```bash
251
+ python binary_classification.py
252
+ python multiclass_classification.py
253
+ python regression.py
254
+ ```
255
+
256
+ ---
257
+
258
+ ## Testing
259
+
260
+ Run the comprehensive test suite (requires pytest):
261
+
262
+ ```bash
263
+ pip install pytest
264
+ pytest tests/ -v
265
+ ```
266
+
267
+ Or run tests with coverage:
268
+
269
+ ```bash
270
+ pip install pytest pytest-cov
271
+ pytest tests/ -v --cov=vanillanets
272
+ ```
273
+
274
+ ### Test Coverage
275
+
276
+ Comprehensive unit and integration tests cover:
277
+ - ✓ All activation functions (Linear, Sigmoid, ReLU, LeakyReLU, Tanh, Softmax) and their derivatives
278
+ - ✓ All loss functions (BCE, CCE, SparseCCE, MSE) with gradient validation
279
+ - ✓ Dense layer forward/backward passes
280
+ - ✓ Optimizer updates (SGD momentum, Adam adaptive rates)
281
+ - ✓ Fused Softmax+CrossEntropy optimization
282
+ - ✓ All metrics (classification & regression)
283
+ - ✓ Model training, evaluation, and prediction workflows
284
+ - ✓ Edge cases and numerical stability
285
+
286
+ ---
287
+
288
+ ## Design Philosophy
289
+
290
+ VanillaNets is built on the principle that **understanding requires transparency**:
291
+
292
+ - **No magic** ✓ Every computation is explicit; no hidden state or black-box frameworks
293
+ - **Learn by reading** ✓ Source code is the primary documentation
294
+ - **Experimentation-friendly** ✓ Modify any component without framework constraints
295
+ - **Pure NumPy** ✓ No external dependencies beyond NumPy for core functionality
296
+ - **Production-ready** ✓ Full test coverage, efficient implementations, stable API
297
+
298
+ ## Use Cases
299
+
300
+ - **Education:** Perfect for coursework on neural networks and deep learning
301
+ - **Research Prototyping:** Experiment with new loss functions, activations, or optimization strategies
302
+ - **Interview Prep:** Implement solutions from scratch during ML engineering interviews
303
+ - **Curriculum Development:** Build course materials with fully transparent implementations
304
+ - **Algorithmic Learning:** Understand backpropagation, gradient descent, and optimizer mechanics
305
+
306
+ ---
307
+
308
+ ## Project Status
309
+
310
+ ### v1.0.0 - Production Ready
311
+
312
+ **Fully Implemented & Tested:**
313
+ - ✓ Dense layer implementation with He, Xavier, normal, and uniform weight initialization
314
+ - ✓ All activation functions with proper gradient computation (Linear, ReLU, LeakyReLU, Tanh, Sigmoid, Softmax)
315
+ - ✓ All loss functions with backward passes (BCE, CCE, SparseCCE, MSE)
316
+ - ✓ SGD optimizer with momentum and learning rate decay
317
+ - ✓ Adam optimizer with adaptive learning rates
318
+ - ✓ Comprehensive metrics suite (Accuracy, Precision, Recall, F1, Confusion Matrix, R², MAE, RMSE)
319
+ - ✓ Full Model API (add, set, finalize, predict, evaluate, fit)
320
+ - ✓ Fused Softmax+CrossEntropy optimization for faster training
321
+ - ✓ Extensive test coverage (50+ test cases)
322
+ - ✓ Complete example applications (binary classification, multiclass classification, regression)
323
+ - ✓ Validation data support during training
324
+
325
+ ### Future Enhancements (Post-v1.0)
326
+ - Convolutional (Conv2D) layers with pooling
327
+ - Recurrent layers (LSTM, GRU)
328
+ - Batch normalization and layer normalization
329
+ - Dropout regularization
330
+ - Custom layer support through base class
331
+ - Learning rate scheduling
332
+ - Distributed training utilities (multi-GPU)
333
+ - Quantization and pruning support
334
+
335
+ ---
336
+
337
+ ## License
338
+
339
+ MIT License - See [LICENSE](LICENSE) for full details.
340
+
341
+ You are free to use, modify, and distribute this software for any purpose (commercial or personal) with proper attribution.
342
+
343
+ ---
344
+
345
+ ## Acknowledgments
346
+
347
+ VanillaNets was built with a singular mission: to demystify neural networks for learners everywhere. This library stands on the shoulders of foundational work in deep learning by pioneers like Yann LeCun, Geoffrey Hinton, Yoshua Bengio, and the broader machine learning community.
348
+
349
+ Special thanks to:
350
+ - The NumPy team for creating an incredible numerical computing foundation
351
+ - All educators who emphasize understanding over black-box frameworks
352
+ - Contributors and users who provide feedback and improvements
353
+
354
+ ## Citation
355
+
356
+ If you use VanillaNets in your research or teaching, please cite:
357
+
358
+ ```bibtex
359
+ @software{vanillanets2026,
360
+ title={VanillaNets: A Transparent Neural Network Library},
361
+ author={Umar Balak},
362
+ year={2026},
363
+ url={https://github.com/UmarBalak/vanillanets}
364
+ }
365
+ ```
366
+
367
+ ---
368
+
369
+ ## Resources & References
370
+
371
+ ### Recommended Reading
372
+ - **Neural Networks from Scratch in Python**, co-authored by Harrison Kinsley and Daniel Kukieła
373
+ - **Deep Learning** by Goodfellow, I., Bengio, Y., & Courville, A.
374
+ - **Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow, 3rd Edition** by Aurélien Géron
375
+
376
+
377
+ ### Related Projects
378
+ - [NumPy](https://numpy.org/) - Our computational foundation
379
+ - [3blue1brown Neural Network Series](https://www.youtube.com/watch?v=aircAruvnKk) - Visual learning guide
380
+
381
+ ---
382
+
383
+ **Built with ❤️ for learners by learners.**