update readme

This commit is contained in:
George Hotz
2020-10-18 14:32:45 -07:00
parent 4724b5e5b9
commit 28100c741f

View File

@@ -37,6 +37,25 @@ print(x.grad) # dz/dx
print(y.grad) # dz/dy
```
### You can even train neural networks with tinygrad (from test/mnist.py)
```python
from tinygrad.tensor import Tensor
import tinygrad.optim as optim
class TinyBobNet:
def __init__(self):
self.l1 = Tensor(layer_init(784, 128))
self.l2 = Tensor(layer_init(128, 10))
def forward(self, x):
return x.dot(self.l1).relu().dot(self.l2).logsoftmax()
model = TinyBobNet()
optim = optim.SGD([model.l1, model.l2], lr=0.001)
# ... and complete like pytorch
```
### TODO (to make real neural network library)