{"id":24300700,"url":"https://github.com/paulopacitti/undergrad","last_synced_at":"2025-07-22T17:34:58.221Z","repository":{"id":218392476,"uuid":"721375978","full_name":"paulopacitti/undergrad","owner":"paulopacitti","description":"🎓 super small and cute neural net engine, using only numpy","archived":false,"fork":false,"pushed_at":"2024-07-17T01:26:05.000Z","size":1085,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-06T12:52:49.664Z","etag":null,"topics":["machine-learning","micrograd","neural-networks","nn","tinygrad"],"latest_commit_sha":null,"homepage":"","language":"Python","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/paulopacitti.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":"2023-11-20T23:48:46.000Z","updated_at":"2025-03-05T15:26:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"66bc39dc-b2b4-4346-9d6f-84b6e26a5abc","html_url":"https://github.com/paulopacitti/undergrad","commit_stats":null,"previous_names":["paulopacitti/undergrad"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/paulopacitti/undergrad","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulopacitti%2Fundergrad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulopacitti%2Fundergrad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulopacitti%2Fundergrad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulopacitti%2Fundergrad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paulopacitti","download_url":"https://codeload.github.com/paulopacitti/undergrad/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulopacitti%2Fundergrad/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266540155,"owners_count":23945162,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"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":["machine-learning","micrograd","neural-networks","nn","tinygrad"],"created_at":"2025-01-16T23:16:04.851Z","updated_at":"2025-07-22T17:34:58.199Z","avatar_url":"https://github.com/paulopacitti.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# undergrad 🎓\nA super small and cute neural net engine, using only `numpy`.\n\n![a bear in a graduation party](https://raw.githubusercontent.com/paulopacitti/undergrad/main/docs/bear_graduate.jpg)\n\nInspired by [micrograd](https://github.com/karpathy/micrograd) and [teenygrad](https://github.com/tinygrad/teenygrad), `undergrad` is a small and cute library to build neural nets. The library uses just `numpy` for better understanding what is happening behind the scenes, encouraging developers to learn machine learning theory from the source code.\n\nThis is the neural net engine I've built while I was doing the Machine Learning course in my Computer Engineering bachelor's, at [UNICAMP](https://en.wikipedia.org/wiki/State_University_of_Campinas). After the course, I've been improving to be a proper well-documented library.\n\n**The written documentation is done by docstrings throughout the source code. That way, you can learn how neural networks work from scratch by reading the code.** \nThe API is not pytorch-like, still, it's very intuitive for newcomers to machine learning.\n\n- `undergrad.model`: model builder and layers (`Dense` only for now).\n- `undergrad.trainer`: trainer module\n- `undergrad.ops`: activation functions, loss functions and other machine learning operations.\n- `undergrad.optim`: optimizers.\n- `undergrad.metrics`: model evaluation functions.\n\n## FAQ\n\n- **You lied, I see you're using dependencies other then just `numpy`! 😡**\n  \n  The `undergrad` engine uses only `numpy`, `tqdm` and `torch.utils.data`, because it uses PyTorch's `Dataloader` to do load data when iterating over the data to train and evaluate. The `examples/` folder uses other dependencies for loading and transforming the datasets before feeding them to models, but these are not part of the `undergrad` library. However, **the neural net engine and operations use only numpy as external dependency** (I encourage you to check in the source code, my friend).\n\n- **How do I use it?**\n\n  Check the `examples/` folder and read the source code, I've trained to explain everything thru the docstrings 😉\n\n\n- **This is better than tinygrad?**\n  \n  No, it is not, not even close. But I think it's way simpler to understand simply because `undergrad` uses `numpy` instead of building a complex Tensor module. Also, the gradients equations are declared for each machine learning operation as a function, so it's easier to understand what's happening without something like `autograd`.\n\n## Benchmarks\n- [MNIST](https://en.wikipedia.org/wiki/MNIST_database):\n  \n  ```bash\n  ➜ paulopacitti undergrad git:(main) ✗ python examples/mnist.py\n    [training]:\n    100%|███████████████████████████████████████████████████████████| 20/20 [01:17\u003c00:00,  3.89s/it]\n    [balanced_accuracy_score]: 0.9484\n    [accuracy_for_class]:\n        class: 0    accuracy: 0.9730\n        class: 1    accuracy: 0.9771\n        class: 2    accuracy: 0.9727\n        class: 3    accuracy: 0.9055\n        class: 4    accuracy: 0.9169\n        class: 5    accuracy: 0.9431\n        class: 6    accuracy: 0.9664\n        class: 7    accuracy: 0.9595\n        class: 8    accuracy: 0.9129\n        class: 9    accuracy: 0.9571\n  ```\n\n## Contributing\n\nFeel free to take part on this project to help building `undergrad`, a library that teaches beginners how neural nets work.\n\n### Roadmap\n- [x] Write framework;\n- [x] MNIST demo;\n- [x] Add typing hint to undergrad modules;\n- [x] Add documentation as comments throughout the source code;\n- [x] Improve MNIST demo with a better MLP network with better accuracy;\n- [ ] Add convolutional layer construct to `undegrad.ops`;\n- [ ] Add CIFAR10 demo;\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulopacitti%2Fundergrad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaulopacitti%2Fundergrad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulopacitti%2Fundergrad/lists"}