{"id":38869256,"url":"https://github.com/markoelez/minigrad","last_synced_at":"2026-01-17T14:28:12.848Z","repository":{"id":126785501,"uuid":"382950248","full_name":"markoelez/minigrad","owner":"markoelez","description":"Autograd engine and neural net library","archived":false,"fork":false,"pushed_at":"2025-07-01T22:19:00.000Z","size":79,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-01T23:27:46.833Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/markoelez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-07-04T21:18:36.000Z","updated_at":"2025-07-01T22:19:03.000Z","dependencies_parsed_at":"2023-12-10T08:20:04.743Z","dependency_job_id":"781e7781-66ba-4aa0-a692-c976999737b3","html_url":"https://github.com/markoelez/minigrad","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/markoelez/minigrad","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markoelez%2Fminigrad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markoelez%2Fminigrad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markoelez%2Fminigrad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markoelez%2Fminigrad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markoelez","download_url":"https://codeload.github.com/markoelez/minigrad/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markoelez%2Fminigrad/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28509948,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-17T14:28:12.229Z","updated_at":"2026-01-17T14:28:12.842Z","avatar_url":"https://github.com/markoelez.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# minigrad\n\nSimple vector-valued autodiff library.\n\n--------------------------------------------------------------------\n\nInspired by [karpathy/micrograd](https://github.com/karpathy/micrograd) and [pytorch](https://github.com/pytorch/pytorch)\n\n\n## Features\n\n### Nueral Networks\n\nSee `eval/` for concrete implementations.\n\nExample:\n\n```python\nclass NN:\n    def __init__(self):\n        self.l1: Tensor = Tensor.uniform(4, 10)\n        self.l2: Tensor = Tensor.uniform(10, 3)\n\n        self.params = [self.l1, self.l2]\n\n    def forward(self, x):\n        x = x.dot(self.l1)\n        x = x.relu()\n        x = x.dot(self.l2)\n        x = x.softmax()\n        return x\n\n    def __call__(self, x):\n        return self.forward(x)\n\n# input data\nX_train, Y_train, X_test, Y_test = prepare(dataset)\n\nmodel = NN()\noptim = Adam(params=model.params, lr=0.001)\n\nepochs = 1000\nbatch_size = 128\n\nfor _ in (t := trange(epochs)):\n\n    # reset gradients\n    optim.zero_grad()\n\n    # select batch\n    idx = np.random.choice(len(X_train), batch_size, replace=False)\n\n    # initialize tensors\n    x, y = Tensor(X_train[idx]), Tensor(Y_train[idx])\n\n    # forward pass\n    out = model(x)\n\n    # compute loss\n    loss = out.cross_entropy(y)\n\n    # backward pass\n    loss.backward()\n\n    # adjust weights\n    optim.step()\n\n    # eval\n    cat = np.argmax(out.numpy(), axis=-1)\n    accuracy = (cat == np.argmax(y.numpy(), axis=-1)).mean()\n    print(loss, accuracy)\n```\n\nRun with `DEBUG=1` to visualize the resulting computational graph, tensor operations, and gradient shapes:\n\nExample:\n```\n********************************************************************************\n[OP=\u003cclass 'minigrad.ops.CrossEntropy'\u003e]\n---------------\ninput grad:\n---------------\n()\n---------------\noutput grads:\n---------------\n(50, 3)\n()\n********************************************************************************\n[OP=\u003cclass 'minigrad.ops.Div'\u003e]\n---------------\ninput grad:\n---------------\n(50, 3)\n---------------\noutput grads:\n---------------\n(50, 3)\n(50, 3)\n********************************************************************************\n[OP=\u003cclass 'minigrad.ops.Expand'\u003e]\n---------------\ninput grad:\n---------------\n(50, 3)\n---------------\noutput grads:\n---------------\n(50, 1)\n********************************************************************************\n[OP=\u003cclass 'minigrad.ops.Sum'\u003e]\n---------------\ninput grad:\n---------------\n(50, 1)\n---------------\noutput grads:\n---------------\n(50, 3)\n********************************************************************************\n[OP=\u003cclass 'minigrad.ops.Exp'\u003e]\n---------------\ninput grad:\n---------------\n(50, 3)\n---------------\noutput grads:\n---------------\n(50, 3)\n********************************************************************************\n```\n\nRun with `DEBUG=2` to visualize the above in addition to computed gradients.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkoelez%2Fminigrad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkoelez%2Fminigrad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkoelez%2Fminigrad/lists"}