forgeNN


NameforgeNN JSON
Version 1.1.0.1 PyPI version JSON
download
home_pagehttps://github.com/Savernish/forgeNN
SummaryA From Scratch Neural Network Framework with Educational Purposes
upload_time2025-09-08 10:35:52
maintainerNone
docs_urlNone
authorEnbiya Çabuk
requires_python>=3.8
licenseMIT License Copyright (c) 2025 Enbiya Çabuk Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords neural-networks machine-learning deep-learning education automatic-differentiation numpy vectorized from-scratch ai artificial-intelligence
VCS
bugtrack_url
requirements numpy scikit-learn pytest pytest-cov sphinx sphinx-rtd-theme matplotlib jupyter
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # forgeNN

## Table of Contents

- [Installation](#Installation)
- [Overview](#Overview)
- [Performance vs PyTorch](#Performance-vs-PyTorch)
- [Quick Start](#Quick-Start)
- [Architecture](#Architecture)
- [Performance](#Performance)
- [Complete Example](#Complete-Example)
- [TODO List](#TODO-List)
- [Contributing](#Contributing)
- [Acknowledgments](#Acknowledgments)

[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![NumPy](https://img.shields.io/badge/powered_by-NumPy-blue.svg)](https://numpy.org/)
[![PyPI version](https://img.shields.io/pypi/v/forgeNN.svg)](https://pypi.org/project/forgeNN/)
[![Downloads](https://img.shields.io/pypi/dm/forgeNN.svg)](https://pypi.org/project/forgeNN/)
[![License](https://img.shields.io/pypi/l/forgeNN.svg)](https://pypi.org/project/forgeNN/)

## Installation

```bash
pip install forgeNN
```

## Overview

**forgeNN** is a modern neural network framework that is developed by a solo developer learning about ML. Features vectorized operations for high-speed training.

### Key Features

- **Vectorized Operations**: NumPy-powered batch processing (100x+ speedup)
- **Dynamic Computation Graphs**: Automatic differentiation with gradient tracking
- **Complete Neural Networks**: From simple neurons to complex architectures
- **Production Loss Functions**: Cross-entropy, MSE with numerical stability

## Performance vs PyTorch

**forgeNN is 3.52x faster than PyTorch on small models!**

| Metric | PyTorch | forgeNN | Advantage |
|--------|---------|---------|-----------|
| Training Time (MNIST) | 64.72s | 30.84s | **2.10x faster** |
| Test Accuracy | 97.30% | 97.37% | **+0.07% better** |
| Small Models (<109k params) | Baseline | **3.52x faster** | **Massive speedup** |

📊 **[See Full Comparison Guide](COMPARISON_GUIDE.md)** for detailed benchmarks, syntax differences, and when to use each framework.

![MNIST Benchmark Results](mnist_benchmark_comparison.png)

## Quick Start

### High-Performance Training

```python
import forgeNN
from sklearn.datasets import make_classification

# Generate dataset
X, y = make_classification(n_samples=1000, n_features=20, n_classes=3)

# Create vectorized model  
model = forgeNN.VectorizedMLP(20, [64, 32], 3)
optimizer = forgeNN.VectorizedOptimizer(model.parameters(), lr=0.01)

# Fast batch training
for epoch in range(10):
    # Convert to tensors
    x_batch = forgeNN.Tensor(X)
    
    # Forward pass
    logits = model(x_batch)
    loss = forgeNN.cross_entropy_loss(logits, y)
    
    # Backward pass
    optimizer.zero_grad()
    loss.backward()
    optimizer.step()
    
    acc = forgeNN.accuracy(logits, y)
    print(f"Epoch {epoch}: Loss = {loss.data:.4f}, Acc = {acc*100:.1f}%")
```

## Architecture

- **Main API**: `forgeNN.Tensor`, `forgeNN.VectorizedMLP` (high-performance neural networks)
- **Activation Functions**: `forgeNN.RELU`, `forgeNN.SWISH`, etc. + string/callable support
- **Examples**: `example.py` - Complete MNIST classification demo

## Performance

| Implementation | Speed | MNIST Accuracy |
|---------------|-------|----------------|
| Vectorized | 38,000+ samples/sec | 93%+ in <2s |

**Highlights**:
- **100x+ speedup** over scalar implementations
- **Production-ready** performance with educational clarity
- **Memory efficient** vectorized operations

## Complete Example

See `example.py` for a full MNIST classification demo achieving professional results.

## Links

- **PyPI Package**: https://pypi.org/project/forgeNN/
- **Documentation**: See guides in this repository
- **Issues**: GitHub Issues for bug reports and feature requests

## TODO List

Based on comprehensive comparison with PyTorch and NumPy:

### CRITICAL MISSING FEATURES (High Priority):

1. ~TENSOR SHAPE OPERATIONS:~ - COMPLETED
   - `reshape()`      : Change tensor dimensions (tensor.reshape(2, -1)) - COMPLETED
   - `transpose()`    : Swap dimensions (tensor.transpose(0, 1)) - COMPLETED
   - `view()`         : Memory-efficient reshape (tensor.view(-1, 5)) - COMPLETED
   - `flatten()`      : Convert to 1D (tensor.flatten()) - COMPLETED
   - `squeeze()`      : Remove size-1 dims (tensor.squeeze()) - COMPLETED
   - `unsqueeze()`    : Add size-1 dims (tensor.unsqueeze(0)) - COMPLETED

2. ~MATRIX OPERATIONS:~ - COMPLETED
   - `matmul()` / `@`  : Matrix multiplication with broadcasting - COMPLETED
   - `dot()`          : Vector dot product for 1D arrays - COMPLETED

3. TENSOR COMBINATION:
   - `cat()`          : Join along existing dim (torch.cat([a, b], dim=0))
   - `stack()`        : Join along new dim (torch.stack([a, b]))

### IMPORTANT FEATURES (Medium Priority):

4. ADVANCED ACTIVATIONS:
   - `lrelu()`       : AVAILABLE as `forgeNN.functions.activation.LRELU` (needs fixing) - FIXED
   - `swish()`       : AVAILABLE as `forgeNN.functions.activation.SWISH` (needs fixing) - FIXED
   - `gelu()`         : Gaussian Error Linear Unit (missing) - ADDED
   - `elu()`          : Exponential Linear Unit (missing)

5. TENSOR UTILITIES:
   - `split()`        : Split into chunks
   - `chunk()`        : Split into equal pieces
   - `permute()`      : Rearrange dimensions
   - `contiguous()` : Make tensor memory-contiguous (tensor.contiguous()) - COMPLETED

6. INDEXING:
   - Boolean indexing: `tensor[tensor > 0]`
   - Fancy indexing: `tensor[indices]`
   - `gather()`       : Select along dimension

### NICE-TO-HAVE (Lower Priority):

7. LINEAR ALGEBRA:
   - `norm()`         : Vector/matrix norms
   - `det()`          : Matrix determinant
   - `inverse()`      : Matrix inverse

8. CONVENIENCE:
   - `clone()`        : Deep copy
   - `detach()`       : Remove from computation graph
   - `requires_grad_()`: In-place grad requirement change

9. INFRASTRUCTURE:
   - Better error messages for shape mismatches
   - Memory-efficient operations
   - API consistency improvements
   - Comprehensive documentation

### PRIORITY ORDER:
1. Shape operations (reshape, transpose, flatten)
2. Matrix multiplication (matmul, @)  
3. Tensor combination (cat, stack)
4. More activations (leaky_relu, gelu)
5. Documentation and error handling

## Contributing

I am not currently accepting contributions, but I'm always open to suggestions and feedback!

## Acknowledgments

- Inspired by educational automatic differentiation tutorials (micrograd)
- Built for both learning and production use
- Optimized with modern NumPy practices
- **Available on PyPI**: `pip install forgeNN`

---

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Savernish/forgeNN",
    "name": "forgeNN",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "neural-networks, machine-learning, deep-learning, education, automatic-differentiation, numpy, vectorized, from-scratch, ai, artificial-intelligence",
    "author": "Enbiya \u00c7abuk",
    "author_email": "cabuk23@itu.edu.tr",
    "download_url": "https://files.pythonhosted.org/packages/6c/a2/ac40183779e64a45344e6a9ef20e023012623c4c1ea345b112c1f17975f4/forgenn-1.1.0.1.tar.gz",
    "platform": null,
    "description": "# forgeNN\r\n\r\n## Table of Contents\r\n\r\n- [Installation](#Installation)\r\n- [Overview](#Overview)\r\n- [Performance vs PyTorch](#Performance-vs-PyTorch)\r\n- [Quick Start](#Quick-Start)\r\n- [Architecture](#Architecture)\r\n- [Performance](#Performance)\r\n- [Complete Example](#Complete-Example)\r\n- [TODO List](#TODO-List)\r\n- [Contributing](#Contributing)\r\n- [Acknowledgments](#Acknowledgments)\r\n\r\n[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)\r\n[![NumPy](https://img.shields.io/badge/powered_by-NumPy-blue.svg)](https://numpy.org/)\r\n[![PyPI version](https://img.shields.io/pypi/v/forgeNN.svg)](https://pypi.org/project/forgeNN/)\r\n[![Downloads](https://img.shields.io/pypi/dm/forgeNN.svg)](https://pypi.org/project/forgeNN/)\r\n[![License](https://img.shields.io/pypi/l/forgeNN.svg)](https://pypi.org/project/forgeNN/)\r\n\r\n## Installation\r\n\r\n```bash\r\npip install forgeNN\r\n```\r\n\r\n## Overview\r\n\r\n**forgeNN** is a modern neural network framework that is developed by a solo developer learning about ML. Features vectorized operations for high-speed training.\r\n\r\n### Key Features\r\n\r\n- **Vectorized Operations**: NumPy-powered batch processing (100x+ speedup)\r\n- **Dynamic Computation Graphs**: Automatic differentiation with gradient tracking\r\n- **Complete Neural Networks**: From simple neurons to complex architectures\r\n- **Production Loss Functions**: Cross-entropy, MSE with numerical stability\r\n\r\n## Performance vs PyTorch\r\n\r\n**forgeNN is 3.52x faster than PyTorch on small models!**\r\n\r\n| Metric | PyTorch | forgeNN | Advantage |\r\n|--------|---------|---------|-----------|\r\n| Training Time (MNIST) | 64.72s | 30.84s | **2.10x faster** |\r\n| Test Accuracy | 97.30% | 97.37% | **+0.07% better** |\r\n| Small Models (<109k params) | Baseline | **3.52x faster** | **Massive speedup** |\r\n\r\n\ud83d\udcca **[See Full Comparison Guide](COMPARISON_GUIDE.md)** for detailed benchmarks, syntax differences, and when to use each framework.\r\n\r\n![MNIST Benchmark Results](mnist_benchmark_comparison.png)\r\n\r\n## Quick Start\r\n\r\n### High-Performance Training\r\n\r\n```python\r\nimport forgeNN\r\nfrom sklearn.datasets import make_classification\r\n\r\n# Generate dataset\r\nX, y = make_classification(n_samples=1000, n_features=20, n_classes=3)\r\n\r\n# Create vectorized model  \r\nmodel = forgeNN.VectorizedMLP(20, [64, 32], 3)\r\noptimizer = forgeNN.VectorizedOptimizer(model.parameters(), lr=0.01)\r\n\r\n# Fast batch training\r\nfor epoch in range(10):\r\n    # Convert to tensors\r\n    x_batch = forgeNN.Tensor(X)\r\n    \r\n    # Forward pass\r\n    logits = model(x_batch)\r\n    loss = forgeNN.cross_entropy_loss(logits, y)\r\n    \r\n    # Backward pass\r\n    optimizer.zero_grad()\r\n    loss.backward()\r\n    optimizer.step()\r\n    \r\n    acc = forgeNN.accuracy(logits, y)\r\n    print(f\"Epoch {epoch}: Loss = {loss.data:.4f}, Acc = {acc*100:.1f}%\")\r\n```\r\n\r\n## Architecture\r\n\r\n- **Main API**: `forgeNN.Tensor`, `forgeNN.VectorizedMLP` (high-performance neural networks)\r\n- **Activation Functions**: `forgeNN.RELU`, `forgeNN.SWISH`, etc. + string/callable support\r\n- **Examples**: `example.py` - Complete MNIST classification demo\r\n\r\n## Performance\r\n\r\n| Implementation | Speed | MNIST Accuracy |\r\n|---------------|-------|----------------|\r\n| Vectorized | 38,000+ samples/sec | 93%+ in <2s |\r\n\r\n**Highlights**:\r\n- **100x+ speedup** over scalar implementations\r\n- **Production-ready** performance with educational clarity\r\n- **Memory efficient** vectorized operations\r\n\r\n## Complete Example\r\n\r\nSee `example.py` for a full MNIST classification demo achieving professional results.\r\n\r\n## Links\r\n\r\n- **PyPI Package**: https://pypi.org/project/forgeNN/\r\n- **Documentation**: See guides in this repository\r\n- **Issues**: GitHub Issues for bug reports and feature requests\r\n\r\n## TODO List\r\n\r\nBased on comprehensive comparison with PyTorch and NumPy:\r\n\r\n### CRITICAL MISSING FEATURES (High Priority):\r\n\r\n1. ~TENSOR SHAPE OPERATIONS:~ - COMPLETED\r\n   - `reshape()`      : Change tensor dimensions (tensor.reshape(2, -1)) - COMPLETED\r\n   - `transpose()`    : Swap dimensions (tensor.transpose(0, 1)) - COMPLETED\r\n   - `view()`         : Memory-efficient reshape (tensor.view(-1, 5)) - COMPLETED\r\n   - `flatten()`      : Convert to 1D (tensor.flatten()) - COMPLETED\r\n   - `squeeze()`      : Remove size-1 dims (tensor.squeeze()) - COMPLETED\r\n   - `unsqueeze()`    : Add size-1 dims (tensor.unsqueeze(0)) - COMPLETED\r\n\r\n2. ~MATRIX OPERATIONS:~ - COMPLETED\r\n   - `matmul()` / `@`  : Matrix multiplication with broadcasting - COMPLETED\r\n   - `dot()`          : Vector dot product for 1D arrays - COMPLETED\r\n\r\n3. TENSOR COMBINATION:\r\n   - `cat()`          : Join along existing dim (torch.cat([a, b], dim=0))\r\n   - `stack()`        : Join along new dim (torch.stack([a, b]))\r\n\r\n### IMPORTANT FEATURES (Medium Priority):\r\n\r\n4. ADVANCED ACTIVATIONS:\r\n   - `lrelu()`       : AVAILABLE as `forgeNN.functions.activation.LRELU` (needs fixing) - FIXED\r\n   - `swish()`       : AVAILABLE as `forgeNN.functions.activation.SWISH` (needs fixing) - FIXED\r\n   - `gelu()`         : Gaussian Error Linear Unit (missing) - ADDED\r\n   - `elu()`          : Exponential Linear Unit (missing)\r\n\r\n5. TENSOR UTILITIES:\r\n   - `split()`        : Split into chunks\r\n   - `chunk()`        : Split into equal pieces\r\n   - `permute()`      : Rearrange dimensions\r\n   - `contiguous()` : Make tensor memory-contiguous (tensor.contiguous()) - COMPLETED\r\n\r\n6. INDEXING:\r\n   - Boolean indexing: `tensor[tensor > 0]`\r\n   - Fancy indexing: `tensor[indices]`\r\n   - `gather()`       : Select along dimension\r\n\r\n### NICE-TO-HAVE (Lower Priority):\r\n\r\n7. LINEAR ALGEBRA:\r\n   - `norm()`         : Vector/matrix norms\r\n   - `det()`          : Matrix determinant\r\n   - `inverse()`      : Matrix inverse\r\n\r\n8. CONVENIENCE:\r\n   - `clone()`        : Deep copy\r\n   - `detach()`       : Remove from computation graph\r\n   - `requires_grad_()`: In-place grad requirement change\r\n\r\n9. INFRASTRUCTURE:\r\n   - Better error messages for shape mismatches\r\n   - Memory-efficient operations\r\n   - API consistency improvements\r\n   - Comprehensive documentation\r\n\r\n### PRIORITY ORDER:\r\n1. Shape operations (reshape, transpose, flatten)\r\n2. Matrix multiplication (matmul, @)  \r\n3. Tensor combination (cat, stack)\r\n4. More activations (leaky_relu, gelu)\r\n5. Documentation and error handling\r\n\r\n## Contributing\r\n\r\nI am not currently accepting contributions, but I'm always open to suggestions and feedback!\r\n\r\n## Acknowledgments\r\n\r\n- Inspired by educational automatic differentiation tutorials (micrograd)\r\n- Built for both learning and production use\r\n- Optimized with modern NumPy practices\r\n- **Available on PyPI**: `pip install forgeNN`\r\n\r\n---\r\n",
    "bugtrack_url": null,
    "license": "MIT License\r\n        \r\n        Copyright (c) 2025 Enbiya \u00c7abuk\r\n        \r\n        Permission is hereby granted, free of charge, to any person obtaining a copy\r\n        of this software and associated documentation files (the \"Software\"), to deal\r\n        in the Software without restriction, including without limitation the rights\r\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n        copies of the Software, and to permit persons to whom the Software is\r\n        furnished to do so, subject to the following conditions:\r\n        \r\n        The above copyright notice and this permission notice shall be included in all\r\n        copies or substantial portions of the Software.\r\n        \r\n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n        SOFTWARE.\r\n        ",
    "summary": "A From Scratch Neural Network Framework with Educational Purposes",
    "version": "1.1.0.1",
    "project_urls": {
        "Bug Reports": "https://github.com/Savernish/forgeNN/issues",
        "Changelog": "https://github.com/Savernish/forgeNN/blob/main/CHANGELOG.md",
        "Documentation": "https://github.com/Savernish/forgeNN/blob/main/README.md",
        "Homepage": "https://github.com/Savernish/forgeNN",
        "Repository": "https://github.com/Savernish/forgeNN.git"
    },
    "split_keywords": [
        "neural-networks",
        " machine-learning",
        " deep-learning",
        " education",
        " automatic-differentiation",
        " numpy",
        " vectorized",
        " from-scratch",
        " ai",
        " artificial-intelligence"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4288f0397a1cb4e2ab4873da90114922b6e20fcb25d2971cfbfca80e1e9c9c12",
                "md5": "5d10cfe11c4efa80e3b4dcd7d5584b11",
                "sha256": "2bd8dd21ae2e68f830934c1ed491fb3222fb0f3565516cbad51d134bd208d046"
            },
            "downloads": -1,
            "filename": "forgenn-1.1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5d10cfe11c4efa80e3b4dcd7d5584b11",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 19804,
            "upload_time": "2025-09-08T10:35:51",
            "upload_time_iso_8601": "2025-09-08T10:35:51.293454Z",
            "url": "https://files.pythonhosted.org/packages/42/88/f0397a1cb4e2ab4873da90114922b6e20fcb25d2971cfbfca80e1e9c9c12/forgenn-1.1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6ca2ac40183779e64a45344e6a9ef20e023012623c4c1ea345b112c1f17975f4",
                "md5": "e06a9b1e98ec6ed56b1a8f25265fbf14",
                "sha256": "4b2200ee7734a97d352ea5e8a2f4df73409de29fb53424f2575f86581a53a638"
            },
            "downloads": -1,
            "filename": "forgenn-1.1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "e06a9b1e98ec6ed56b1a8f25265fbf14",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 32014,
            "upload_time": "2025-09-08T10:35:52",
            "upload_time_iso_8601": "2025-09-08T10:35:52.918520Z",
            "url": "https://files.pythonhosted.org/packages/6c/a2/ac40183779e64a45344e6a9ef20e023012623c4c1ea345b112c1f17975f4/forgenn-1.1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-08 10:35:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Savernish",
    "github_project": "forgeNN",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "numpy",
            "specs": [
                [
                    ">=",
                    "1.20.0"
                ]
            ]
        },
        {
            "name": "scikit-learn",
            "specs": [
                [
                    ">=",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    ">=",
                    "7.0.0"
                ]
            ]
        },
        {
            "name": "pytest-cov",
            "specs": [
                [
                    ">=",
                    "4.0.0"
                ]
            ]
        },
        {
            "name": "sphinx",
            "specs": [
                [
                    ">=",
                    "4.0.0"
                ]
            ]
        },
        {
            "name": "sphinx-rtd-theme",
            "specs": [
                [
                    ">=",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "matplotlib",
            "specs": [
                [
                    ">=",
                    "3.5.0"
                ]
            ]
        },
        {
            "name": "jupyter",
            "specs": [
                [
                    ">=",
                    "1.0.0"
                ]
            ]
        }
    ],
    "lcname": "forgenn"
}
        
Elapsed time: 1.37032s