https://github.com/lewisnjue/nnetflow

nnetflow framework

https://github.com/lewisnjue/nnetflow

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (6.1%) to scientific vocabulary

Keywords

autograd deeplearning machinelearning nnetflow numpy-with-autograd
Last synced: 6 months ago · JSON representation

Repository

nnetflow framework

Basic Info
  • Host: GitHub
  • Owner: lewisnjue
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 23.8 MB
Statistics
  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
autograd deeplearning machinelearning nnetflow numpy-with-autograd
Created 9 months ago · Last pushed 7 months ago
Metadata Files
Readme License

README.md

nnetflow

A minimal neural network framework with autodiff, inspired by micrograd and pytorch.

Installation

bash pip install nnetflow

```bash

from nnetflow.engine import Tensor from nnetflow.layers import Linear from nnetflow.module import Module from nnetflow.optim import SGD import numpy as np

Define a simple MLP

class MLP(Module): def init(self, indim, hiddendim, outdim): super().init() self.fc1 = Linear(indim, hiddendim) self.fc2 = Linear(hiddendim, out_dim)

def forward(self, x):
    x = self.fc1(x).relu()
    x = self.fc2(x)
    return x

Generate dummy data

np.random.seed(0) X = np.random.randn(100, 3).astype(np.float32) y = (np.random.randn(100, 1) > 0).astype(np.float32)

Convert to Tensor

Xtensor = Tensor(X, requiregrad=False) ytensor = Tensor(y, requiregrad=False)

Instantiate model, loss, optimizer

model = MLP(3, 8, 1) optimizer = SGD(model.parameters(), lr=0.1)

Training loop

for epoch in range(10): optimizer.zerograd() out = model(Xtensor) # Simple MSE loss loss = ((out - y_tensor) ** 2).mean() loss.backward() optimizer.step() print(f"Epoch {epoch}, Loss: {loss.item():.4f}")

model.save("mlp_model.pkl")

Load the model

loadedmodel = Module.load("mlpmodel.pkl")

Verify loaded model

print(f"Loaded model: {loaded_model}")

Check if the loaded model can still perform inference

testout = loadedmodel(Xtensor) print(f"Test output from loaded model: {testout.data[:5]}") # Print first 5 outputs

Check if the loaded model's parameters match the original model's parameters

for originalparam, loadedparam in zip(model.parameters(), loadedmodel.parameters()): assert np.arrayequal(originalparam.data, loadedparam.data), "Loaded parameters do not match original parameters" print("All parameters match successfully after loading the model.") ```

...

See the docs/ folder for more details.

Owner

  • Login: lewisnjue
  • Kind: user

GitHub Events

Total
  • Watch event: 1
  • Delete event: 1
  • Issue comment event: 1
  • Push event: 40
  • Pull request review event: 2
  • Pull request review comment event: 4
  • Create event: 15
Last Year
  • Watch event: 1
  • Delete event: 1
  • Issue comment event: 1
  • Push event: 40
  • Pull request review event: 2
  • Pull request review comment event: 4
  • Create event: 15

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 47
  • Total Committers: 1
  • Avg Commits per committer: 47.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 47
  • Committers: 1
  • Avg Commits per committer: 47.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
lewisnjue 1****e 47

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 457 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 15
  • Total maintainers: 1
pypi.org: nnetflow

A minimal neural network framework with autodiff and NumPy

  • Versions: 15
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 457 Last month
Rankings
Dependent packages count: 9.1%
Average: 30.2%
Dependent repos count: 51.4%
Maintainers (1)
Last synced: 6 months ago

Dependencies

pyproject.toml pypi
  • numpy *
requirements.txt pypi
  • numpy *
setup.py pypi
  • numpy *