/tinybrain

A tiny autograd tensor library written from scratch in TypeScript

Primary LanguageTypeScriptMIT LicenseMIT

A tiny zero-dependency autograd tensor library with PyTorch like syntax, written from scratch in TypeScript

license CI prettier PRs Welcome

This library is a tiny zero-dependency autograd tensor library written from scratch in TypeScript, to learn in depth how everything works and to build intuition. My goal with this project is just to be able to train & run inference on a simple naive MNIST model. I might add convolutions later, if I have time.

Features

  • Inference & training
  • Optimizers (SGD, more coming…)
  • Runs simple MNIST

Usage

import { Tensor } from 'tinybrain';

const x = Tensor.arange(6).reshape(2, 3);
const y = Tensor.uniform(2, 3);
const z = y.mul(x).sum();
z.backward();

console.log(x.grad); // dz/dx
console.log(y.grad); // dz/dy

License

tinybrain is released under the MIT License.

TODO