pygrad/README.md

36 lines
795 B
Markdown
Raw Permalink Normal View History

2020-11-14 23:01:51 +00:00
<p align="center">
<img src="./assets/logo.png" style="max-width: 50%;"/>
</p>
---
2020-11-14 19:27:42 +00:00
Neural network library written in Python completely from scratch, using only numpy.
## Usage
```
from pygrad.tensor import Tensor
2020-11-14 19:27:42 +00:00
a, b = Tensor(np.random.randn(3, 1)), Tensor(np.random.randn(1, 3))
2020-11-14 19:27:42 +00:00
c = a.mul(b)
2020-11-14 20:58:11 +00:00
d = c.exp()
d.backward()
2020-11-14 19:27:42 +00:00
2020-11-14 20:58:11 +00:00
print(a.grad, b.grad, c.grad)
# should output something like
# [[-16.51232262 -16.51232262 -16.51232262]]
# [[-53.88103349 -53.88103349 -53.88103349]]
# [[ 3.50417648 3.50417648 3.50417648]
# [15.67424587 15.67424587 15.67424587]
# [16.0131011 16.0131011 16.0131011 ]]
2020-11-14 19:27:42 +00:00
```
## References
- <https://github.com/geohot/tinygrad/>
- <https://github.com/karpathy/micrograd/>
## Copying
This is free and unencumbered software released into the public domain.