Micrograd is a tiny Autograd engine created
by Andrej Karpathy. This app recreates the
demo
he prepared for this package using pyscript to train a basic model, written in Python, natively in
the browser.
You may run each Python REPL cell interactively by pressing (Shift + Enter) or (Ctrl + Enter).
You can also modify the code directly as you wish. If you want to run all the code at once,
not each cell individually, you may instead click the 'Run All' button. Training the model
takes between 1-2 min if you decide to 'Run All' at once. 'Run All' is your only option if
you are running this on a mobile device where you cannot press (Shift + Enter). After the
model is trained, a plot image should be displayed depicting the model's ability to
classify the data.
Currently the > symbol is being imported incorrectly as > into the REPL's.
In this app the > symbol has been replaced with ().__gt__() so you can run the code
without issue. Ex: instead of a > b, you will see (a).__gt__(b) instead.
accuracy = [(yi > 0) == (scorei.data > 0) for yi, scorei in zip(yb, scores)]accuracy = [((yi).__gt__(0)) == ((scorei.data).__gt__(0)) for yi, scorei in zip(yb, scores)]
Please wait for the training loop above to complete. It will not print out stats until it
has completely finished. This typically takes 1-2 min.
Line 9 has been changed from:
Z = np.array([s.data > 0 for s in scores])
to:
Z = np.array([(s.data).__gt__(0) for s in scores])