Simple Neural Networks
This is a repo for building a simple Neural Net based only on Numpy.
The usage is similar to Pytorch. There are only limited codes involved to be functional. Unlike those popular but complex packages such as Tensorflow and Pytorch, you can dig into my source codes smoothly.
The main purpose of this repo is for you to understand the code rather than implementation. So please feel free to read the codes.
Simple usage
Build a network with a python class and train it.
import npnet
class Net(npnet.Module):
def __init__(self):
super().__init__()
self.l1 = npnet.layers.Dense(n_in=1, n_out=10, activation=npnet.act.tanh)
self.out = npnet.layers.Dense(10, 1)
def forward(self, x):
x = self.l1(x)
o = self.out(x)
return o
The training procedure starts by defining an optimizer and loss.
net = Net()
opt = npnet.optim.Adam(net.params, lr=0.1)
loss_fn = npnet.losses.MSE()
for _ in range(1000):
o = net.forward(x)
loss = loss_fn(o, y)
net.backward(loss)
opt.step()
Demo
- A naked and step-by-step network without using my module.
- Train regressor
- Train classifier
- Train CNN
- Save and restore a trained net
Install
pip install npnet
Download or fork
Download link
Fork this repo:
$ git clone https://github.com/MorvanZhou/npnet.git
Results
Metadata
Release files for npnet 0.0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| npnet-0.0.10.tar.gz | 12.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| npnet-0.0.10-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.2 kB
Release files / npnet-0.0.10.tar.gz
| Download URL | npnet-0.0.10.tar.gz |
|---|---|
| Size | 12.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b881b5f926f4c4509ab8795c90dab78659da5b172639d5838d7fba11e5fb19f5
|
|
BLAKE2b-256 checksum How to use checksums |
8a83aaa4370562f88f7f63b68c0e839fc5f357133cbf2749f0466bf837246e94
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.13
|
Release files / npnet-0.0.10-py3-none-any.whl
| Download URL | npnet-0.0.10-py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a1e38952af8767b8eb078e309c807690468911c1fb3f9a8be3041a29fd6d70bc
|
|
BLAKE2b-256 checksum How to use checksums |
72a3fe34105090f20527f91132816ee2523f6f8f1dd0b8929d64c72c51ea2a1a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.13
|
Security for npnet 0.0.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.