{"id":15902286,"url":"https://github.com/hallerpatrick/phgrad","last_synced_at":"2026-01-21T17:02:34.791Z","repository":{"id":205690925,"uuid":"709505208","full_name":"HallerPatrick/phgrad","owner":"HallerPatrick","description":"phgrad - Cause there are not enough unusable autograd libraries in python","archived":false,"fork":false,"pushed_at":"2024-08-01T19:52:55.000Z","size":1904,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-10T06:53:46.659Z","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/HallerPatrick.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}},"created_at":"2023-10-24T20:22:40.000Z","updated_at":"2024-08-01T19:52:58.000Z","dependencies_parsed_at":"2023-11-10T13:03:22.140Z","dependency_job_id":"68356470-385e-4ae3-bd35-8d56e76ca26a","html_url":"https://github.com/HallerPatrick/phgrad","commit_stats":null,"previous_names":["hallerpatrick/phgrad"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/HallerPatrick/phgrad","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HallerPatrick%2Fphgrad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HallerPatrick%2Fphgrad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HallerPatrick%2Fphgrad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HallerPatrick%2Fphgrad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HallerPatrick","download_url":"https://codeload.github.com/HallerPatrick/phgrad/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HallerPatrick%2Fphgrad/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28636655,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T15:01:31.228Z","status":"ssl_error","status_checked_at":"2026-01-21T14:42:58.942Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":"2024-10-06T11:23:35.124Z","updated_at":"2026-01-21T17:02:34.773Z","avatar_url":"https://github.com/HallerPatrick.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# phgrad \n\n### Cause there are not enough unusable autograd libraries in python\n\n![Logo](logo.png)\n\nA tiny [autograd](https://en.wikipedia.org/wiki/Automatic_differentiation) library for learning purposes, inspired by [micrograd](https://github.com/karpathy/micrograd/tree/master)\nand [tinygrad](https://github.com/tinygrad/tinygrad).\n\nEverything at this point is experimental and not optimized for performance. So be aware that if you\ntouch this library, you will probably break something.\nThe goal is to optimize the library for performance and add more features. I will mostly adjust this library to \nbe usable in NLP tasks.\n\nI will try to keep the API as close as possible to [PyTorch](https://pytorch.org/). A goal is to\nprovide CUDA support, while keeping the dependency list as small as possible. (Currently only numpy, and now cupy).\n\nThe [example](./examples) folder will contain some examples of how to use the library.\n\n\n### Example\n\n```python\nfrom phgrad.engine import Tensor\nfrom phgrad.nn import Linear, Module\n\n# We now have cuda support!\ndevice = \"cuda\"\n\nclass MLP(Module):\n    \"\"\"A simple Multi Layer Perceptron.\"\"\"\n\n    def __init__(\n        self,\n        inp_dim: int,\n        hidden_size: int,\n        output_dim: int,\n        bias: bool = True,\n    ):\n        super().__init__()\n        self.l1 = Linear(inp_dim, hidden_size, bias=bias)\n        self.l2 = Linear(hidden_size, output_dim, bias=bias)\n\n    def forward(self, x: Tensor) -\u003e Tensor:\n        x = self.l1(x)\n        x = x.relu()\n        x = self.l2(x)\n        return x\n\nmodel = MLP(784, 256, 10).to(device)\nx = Tensor(np.random.randn(32, 784), device=device)\ny = model(x).mean()\ny.backward()\n```\n\n\n### Resources\n1. https://github.com/torch/nn/blob/master/doc/transfer.md\n2. https://github.com/karpathy/micrograd/tree/master\n3. https://github.com/geohot/ai-notebooks/blob/master/mnist_from_scratch.ipynb\n4. https://github.com/ICEORY/softmax_loss_gradient\n5. https://notesbylex.com/negative-log-likelihood#:~:text=Negative%20log%2Dlikelihood%20is%20a,all%20items%20in%20the%20batch.\n6. https://github.com/huggingface/candle/tree/main\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhallerpatrick%2Fphgrad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhallerpatrick%2Fphgrad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhallerpatrick%2Fphgrad/lists"}