Micronets
Micronets is a python framework for the simple implementation and training of deep neural networks. The project consists of a small auto-gradient engine module which implements back propagation through a DAG (Directed Acyclic Graph) and a module resembling the PyTorch/Tensorflow APIs to create and train dense neural networks on top of it.
The package also provides additional functionalities such as plotting of the training curve, make predictions and visualisation of computational graphs after training
Installation
pip install micronets
Usage
1. Building Computational Graphs
from micronets.autograd_engine import Value
from micronets.graph import draw
#inputs
x1 = Value(2.0,label='x1')
x2 = Value(4.0, label='x2')
#weights
w1 = Value(-3.0,label='w1')
w2 = Value(1.0,label='w2')
#bias
b = Value(3.3,label='b')
x1w1=x1*w1; x1w1.label='x1*w1'
x2w2=x2*w2; x2w2.label='x2*w2'
x1w1x2w2 = x1w1+x2w2; x1w1x2w2.label='x1w1 + x2w2'
z = x1w1x2w2 + b; z.label='z'
output = z.tanh(); output.label='output'
output.backward()
draw(output)
2. Neural Net Implementation
from micronets.nn import DNN # Dense Neural Network
from micronets.losses import binary_cross_entropy
xs = [
[2.0, 3.0, -1.0],
[3.0, -1.0, 0.5],
[-0.5, -1.0, -1.0],
[-1.0, -1.0, 0.5]
]
ys = [1.0, 0.0, 1.0, 0.0]
model = DNN(input_features=3, layers=[2,2,1], activations=['relu', 'relu', 'sigmoid']) # creates model architecture
history, graph = model.train(X=xs, Y=ys, iterations=500, loss_function=binary_cross_entropy, learning_rate=0.1) # trains network and stores loss function history and computational graph
predictions = model.predict([ # outputs predictions
[2.0, -1.0, 3.5],
[-1.0, -3.0, 0.5]
])
model.plot(history) # plots learning curve
Additionally the playground.ipynb file demonstrates functionality through a more complex example along with its outputs.
Lastly, a big thank you to Andrej Karpathy for inspiring this project :)
License
MIT
Release files for micronets 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| micronets-0.1.2.tar.gz | 5.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| micronets-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.5 kB
Release files / micronets-0.1.2.tar.gz
| Download URL | micronets-0.1.2.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0c500f912492789f1e22c0719e4cab1168c765c8419d538d33a7fe1a23e0762e
|
|
BLAKE2b-256 checksum How to use checksums |
bb0bba0b3fc09bbefa3deefe5d198c2f9c65c2d73739c91e0f3fd92627de26f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.6
|
Release files / micronets-0.1.2-py3-none-any.whl
| Download URL | micronets-0.1.2-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b28b43c0be12f308f92e60a07af84e16fce5d34746eed29cd8c015ce78a853e
|
|
BLAKE2b-256 checksum How to use checksums |
d808ed92c87bd321d3647991040445e87e936ecfcc335e2668e3275fe700b3ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.6
|