unnet stands for Micro Neural Network
It is a proof-of-concept for self-learning of neural networks, so it simplifies and not try to be as efficient as possible. For example, it's not using tensors but simple floating point numbers.
WARNING: Please do not use in production code.
Let's take this example:
>>> from unnet.grad import Node
>>> a = Node(2.0, name='a')
>>> b = Node(3.0, name='b')
>>> c = Node(1.5, name='c')
>>> # forward propagation
>>> d = a * b
>>> e = d + c + a
>>> print(e)
a * b + c + a = 9.5
>>> # back propagation to calculate the gradients
>>> e.backward()
>>> print(e.grad)
1.0
>>> print(d.grad)
1.0
>>> print(c.grad)
1.0
>>> print(b.grad)
2.0
>>> print(a.grad)
4.0We can imagine that these kind of operations could apply to a neural network performing a forward and backward propagations.
You can see a more detailed example in the Grad Jupyter notebook, which includes plots of the calculated expressions
Let's create an artificial neuron with 2 weights and calculate the output given 2 inputs:
>>> from unnet.nn import Neuron
>>> neuron1 = Neuron(weights=[0.7, 0.8], bias=0.5)
>>> result = neuron1([2.0, 3.0])
>>> print(result)
w1 * x0 + w2 * x1 + bias = 4.300000000000001Let's create an artificial neuron with 2 weights and calculate the output given 2 inputs:
>>> neuron1 = Neuron(weights=[0.5, 0.8], bias=0.2)
>>> neuron2 = Neuron(weights=[0.2, -0.2], bias=0.9)
>>> neuron3 = Neuron(weights=[-0.5, 0.3], bias=-0.2)
>>> neuron4 = Neuron(weights=[-0.2, 0.2], bias=0.4)
>>> layer1 = Layer([neuron1, neuron2])
>>> layer2 = Layer([neuron3, neuron4])
>>> network = Network([layer1, layer2])
>>> results = network([2.0, 3.0])
>>> print(results[0].value, results[1].value)
-1.7900000000000003 -0.18000000000000016You can see a more detailed example in the NN Jupyter notebook, which includes plots of the calculated neuron
This project uses uv for dependency management. If you don't have uv installed:
curl -LsSf https://astral.sh/uv/install.sh | sh- Clone the repository:
git clone https://github.com/yourusername/unnet.git
cd unnet- Install all dependencies (including dev dependencies):
uv sync- Grad notebook - Forward and backward propagation with visualizations
- NN notebook - Neural network training examples
For interactive exploration and testing:
uv run jupyter notebook notebooks/grad.ipynb
uv run jupyter notebook notebooks/nn.ipynbWe welcome contributions! If you'd like to contribute to unnet, please see our Contributing Guide
For questions or issues, please open an issue on GitHub.