{"id":13485353,"url":"https://github.com/elinx/ugrad","last_synced_at":"2026-01-17T10:44:44.039Z","repository":{"id":68965977,"uuid":"261198200","full_name":"elinx/ugrad","owner":"elinx","description":"A C++ implementation of the scalar-valued autograd engine micrograd","archived":false,"fork":false,"pushed_at":"2020-05-16T16:27:49.000Z","size":2612,"stargazers_count":21,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-30T20:43:44.026Z","etag":null,"topics":["autodiff","autograd","deep-learning","machine-learning-systems","micrograd","tinygrad"],"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/elinx.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}},"created_at":"2020-05-04T14:09:07.000Z","updated_at":"2024-04-05T15:33:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"8a3274b6-6756-4aea-8793-96ecdf344416","html_url":"https://github.com/elinx/ugrad","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elinx%2Fugrad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elinx%2Fugrad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elinx%2Fugrad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elinx%2Fugrad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elinx","download_url":"https://codeload.github.com/elinx/ugrad/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245910721,"owners_count":20692492,"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":["autodiff","autograd","deep-learning","machine-learning-systems","micrograd","tinygrad"],"created_at":"2024-07-31T18:00:20.039Z","updated_at":"2026-01-17T10:44:43.991Z","avatar_url":"https://github.com/elinx.png","language":"C++","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# ugrad\nA C++ implementation of the scalar-valued autograd engine [micrograd](https://github.com/karpathy/micrograd)\n\n## Example Usage\n```c++\n#include \u003ciostream\u003e\n#include \u003cfmt/core.h\u003e\n#include \u003cfmt/ostream.h\u003e\n\n#include \u003cugrad/engine.hpp\u003e\n\nusing namespace ugrad;\n\nint main()\n{\n  auto a = make_shared\u003cValue\u003e(-4.0f);\n  auto b = make_shared\u003cValue\u003e(2.0f);\n  auto c = a + b;\n  auto d = a * b + b * b * b;\n  c = c + c + 1;\n  c = c + 1 + c + (-a);\n  d = d + d * 2 + (b + a)-\u003erelu();\n  d = d + 3 * d + (b - a)-\u003erelu();\n  auto e = c - d;\n  auto f = e * e;\n  auto g = f / 2.0;\n  g = g + 10.0 / f;\n  fmt::print(\"g: {}\\n\", *g); // prints 24.7041, the outcome of this forward pass\n  g-\u003ebackward();\n  fmt::print(\"a: {}\\n\", *a); // prints 138.8338, i.e. the numerical value of dg/da\n  fmt::print(\"b: {}\\n\", *b); // prints 645.5773, i.e. the numerical value of dg/db\n  return 0;\n}\n```\n\n## MLP Example\n\n```shell\nread dataset finished, size of X: 100, size of y: 100\nmodel: MLP of[Layer of[ReLUNeuron(2), ReLUNeuron(2), ReLUNeuron(2), ReLUNeuron(2), ReLUNeuron(2), ReLUNeuron(2), ReLUNeuron(2), ReLUNeuron(2), ReLUNeuron(2), ReLUNeuron(2), ReLUNeuron(2), ReLUNeuron(2), ReLUNeuron(2), ReLUNeuron(2), ReLUNeuron(2), ReLUNeuron(2)], Layer of[ReLUNeuron(16), ReLUNeuron(16), ReLUNeuron(16), ReLUNeuron(16), ReLUNeuron(16), ReLUNeuron(16), ReLUNeuron(16), ReLUNeuron(16), ReLUNeuron(16), ReLUNeuron(16), ReLUNeuron(16), ReLUNeuron(16), ReLUNeuron(16), ReLUNeuron(16), ReLUNeuron(16), ReLUNeuron(16)], Layer of[LinearNeuron(16)]]\nnumber of parameters: 337\nepoch 0 loss 1.2725152912873847, accuracy 50.00%, lr: 1.0000\nepoch 1 loss 1.9048338557526878, accuracy 66.00%, lr: 0.9910\nepoch 2 loss 0.7485335053477321, accuracy 70.00%, lr: 0.9820\nepoch 3 loss 0.92274670070065, accuracy 82.00%, lr: 0.9730\nepoch 4 loss 0.3142488652855841, accuracy 85.00%, lr: 0.9640\nepoch 5 loss 0.2910938000612888, accuracy 87.00%, lr: 0.9550\nepoch 6 loss 0.28777670574329695, accuracy 86.00%, lr: 0.9460\nepoch 7 loss 0.2890573596107362, accuracy 92.00%, lr: 0.9370\nepoch 8 loss 0.23966708205580817, accuracy 92.00%, lr: 0.9280\nepoch 9 loss 0.2364786200105814, accuracy 94.00%, lr: 0.9190\nepoch 10 loss 0.2254051355225215, accuracy 92.00%, lr: 0.9100\nepoch 11 loss 0.22035147226006968, accuracy 94.00%, lr: 0.9010\nepoch 12 loss 0.19991848684099722, accuracy 92.00%, lr: 0.8920\nepoch 13 loss 0.20509400679406434, accuracy 95.00%, lr: 0.8830\nepoch 14 loss 0.18829085067792212, accuracy 92.00%, lr: 0.8740\nepoch 15 loss 0.1974543475293526, accuracy 93.00%, lr: 0.8650\nepoch 16 loss 0.17242809209578425, accuracy 92.00%, lr: 0.8560\nepoch 17 loss 0.16186244456015614, accuracy 95.00%, lr: 0.8470\nepoch 18 loss 0.16104795341728673, accuracy 92.00%, lr: 0.8380\nepoch 19 loss 0.17195409065398698, accuracy 95.00%, lr: 0.8290\nepoch 20 loss 0.18654272523260412, accuracy 92.00%, lr: 0.8200\nepoch 21 loss 0.18873687045318108, accuracy 95.00%, lr: 0.8110\nepoch 22 loss 0.11898904791539117, accuracy 95.00%, lr: 0.8020\nepoch 23 loss 0.10374206751321746, accuracy 96.00%, lr: 0.7930\nepoch 24 loss 0.11133809018509823, accuracy 96.00%, lr: 0.7840\nepoch 25 loss 0.0869769948969216, accuracy 97.00%, lr: 0.7750\nepoch 26 loss 0.09244877197388525, accuracy 97.00%, lr: 0.7660\nepoch 27 loss 0.10944969528256565, accuracy 96.00%, lr: 0.7570\nepoch 28 loss 0.14940032092337396, accuracy 95.00%, lr: 0.7480\nepoch 29 loss 0.1128000518442734, accuracy 94.00%, lr: 0.7390\nepoch 30 loss 0.07793686300183608, accuracy 98.00%, lr: 0.7300\nepoch 31 loss 0.09546874752129621, accuracy 97.00%, lr: 0.7210\nepoch 32 loss 0.06806739869763159, accuracy 97.00%, lr: 0.7120\nepoch 33 loss 0.05176941565511138, accuracy 98.00%, lr: 0.7030\nepoch 34 loss 0.05006231679840696, accuracy 99.00%, lr: 0.6940\nepoch 35 loss 0.05062781192019704, accuracy 98.00%, lr: 0.6850\nepoch 36 loss 0.07844651885993426, accuracy 98.00%, lr: 0.6760\nepoch 37 loss 0.08421588994620477, accuracy 97.00%, lr: 0.6670\nepoch 38 loss 0.04321012633792009, accuracy 98.00%, lr: 0.6580\nepoch 39 loss 0.03736974183828634, accuracy 100.00%, lr: 0.6490\nepoch 40 loss 0.04322283539319244, accuracy 98.00%, lr: 0.6400\nepoch 41 loss 0.03445071314616174, accuracy 100.00%, lr: 0.6310\nepoch 42 loss 0.03964836995260649, accuracy 99.00%, lr: 0.6220\nepoch 43 loss 0.030669220672464005, accuracy 100.00%, lr: 0.6130\nepoch 44 loss 0.03181888995654795, accuracy 100.00%, lr: 0.6040\nepoch 45 loss 0.02512036603837519, accuracy 100.00%, lr: 0.5950\nepoch 46 loss 0.032500953145045565, accuracy 100.00%, lr: 0.5860\nepoch 47 loss 0.022972301417005618, accuracy 100.00%, lr: 0.5770\nepoch 48 loss 0.03838832612171553, accuracy 99.00%, lr: 0.5680\nepoch 49 loss 0.017589800872646832, accuracy 100.00%, lr: 0.5590\nepoch 50 loss 0.024005346205426367, accuracy 100.00%, lr: 0.5500\nepoch 51 loss 0.050508980108954264, accuracy 98.00%, lr: 0.5410\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felinx%2Fugrad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felinx%2Fugrad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felinx%2Fugrad/lists"}