{"id":19530031,"url":"https://github.com/goktug97/minigrad","last_synced_at":"2025-04-26T12:30:36.292Z","repository":{"id":57441767,"uuid":"257305352","full_name":"goktug97/minigrad","owner":"goktug97","description":"Autograd Engine for Python Written in Python C-API for Speed","archived":false,"fork":false,"pushed_at":"2023-05-06T10:56:54.000Z","size":53,"stargazers_count":20,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T17:18:54.131Z","etag":null,"topics":["autograd","neural-network","python","python-c-api"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/goktug97.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2020-04-20T14:24:24.000Z","updated_at":"2024-11-14T18:35:35.000Z","dependencies_parsed_at":"2024-11-11T01:30:02.797Z","dependency_job_id":"7677c233-824d-4436-ba00-dea954058bb4","html_url":"https://github.com/goktug97/minigrad","commit_stats":{"total_commits":16,"total_committers":1,"mean_commits":16.0,"dds":0.0,"last_synced_commit":"86ff2b85c8e384b1459999aaededb4690c2fe642"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goktug97%2Fminigrad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goktug97%2Fminigrad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goktug97%2Fminigrad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goktug97%2Fminigrad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goktug97","download_url":"https://codeload.github.com/goktug97/minigrad/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250986192,"owners_count":21518459,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["autograd","neural-network","python","python-c-api"],"created_at":"2024-11-11T01:28:34.173Z","updated_at":"2025-04-26T12:30:35.911Z","avatar_url":"https://github.com/goktug97.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"Minigrad\n==========\n\nAn autograd engine inspired by Karpathy's\n[micrograd](https://github.com/karpathy/micrograd) library. It is a\nDrop-In Replacement but it requires you to cast Python numerical types\nto the Value type.\n\nIt is called minigrad because it is a little bit bigger and more complex in terms of readability than micrograd. Engine is implemented in Python C API so it runs faster.\n\nCurrently, minigrad.nn and micrograd.nn are the same.\n\n## Installation\n\n``` bash\npip install minigrad\n```\n\n## Example usage\n\n``` python\na = Value(-4.0)\nb = Value(2.0)\nc = a + b\nd = a * b + b**3.0 # The power exponent must be Python double not Value.\nc += c + Value(1.0)\nc += Value(1.0) + c + -a\nd += d * Value(2.0) + (b + a).relu()\nd += Value(3.0) * d + (b - a).relu()\ne = c - d\nf = e**2.0\ng = f / Value(2.0)\ng += Value(10.0) / f\nprint(f'{g.data:.4f}') # prints 24.7041, the outcome of this forward pass\ng.backward()\nprint(f'{a.grad:.4f}') # prints 138.8338, i.e. the numerical value of dg/da\nprint(f'{b.grad:.4f}') # prints 645.5773, i.e. the numerical value of dg/db\n```\n\n## Training a neural net\nRefer to\n[demo.ipynb](https://github.com/goktug97/minigrad/tree/master/examples/demo.ipynb)\nexample. It differs from the original implementation in terms of types\nas the library only allows Value to Value operations. For example\n`Value(2.0) * 2.0` is not allowed, so it should be `Value(2.0) * Value(2.0)`.\n\n## Running tests\n\nShould be run under test directory because It will try to import local\nminigrad and fail because of the C extension. Also it requires PyTorch.\n\n``` bash\ncd test\npython -m pytest\n```\n\n## License\nMinigrad is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoktug97%2Fminigrad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoktug97%2Fminigrad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoktug97%2Fminigrad/lists"}