{"id":16157280,"url":"https://github.com/nithinbekal/micrograd","last_synced_at":"2026-02-14T13:02:54.658Z","repository":{"id":217705129,"uuid":"744609678","full_name":"nithinbekal/micrograd","owner":"nithinbekal","description":"A tiny autograd engine in ruby","archived":false,"fork":false,"pushed_at":"2024-01-24T03:12:08.000Z","size":33,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-10T17:46:17.305Z","etag":null,"topics":["machine-learning","neural-networks","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/nithinbekal.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2024-01-17T16:44:17.000Z","updated_at":"2024-01-24T10:06:00.000Z","dependencies_parsed_at":"2024-10-27T19:12:31.347Z","dependency_job_id":"e3b6139c-6e1a-4f34-b12c-dafa0416a2e3","html_url":"https://github.com/nithinbekal/micrograd","commit_stats":null,"previous_names":["nithinbekal/micrograd"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/nithinbekal/micrograd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nithinbekal%2Fmicrograd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nithinbekal%2Fmicrograd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nithinbekal%2Fmicrograd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nithinbekal%2Fmicrograd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nithinbekal","download_url":"https://codeload.github.com/nithinbekal/micrograd/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nithinbekal%2Fmicrograd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29444052,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T12:43:28.304Z","status":"ssl_error","status_checked_at":"2026-02-14T12:43:14.160Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["machine-learning","neural-networks","ruby"],"created_at":"2024-10-10T01:49:04.041Z","updated_at":"2026-02-14T13:02:54.639Z","avatar_url":"https://github.com/nithinbekal.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Micrograd\n\nA tiny autograd engine. This is a Ruby implementation of [karpathy/micrograd](https://github.com/karpathy/micrograd). I created this while working through Andrej Karpathy's [Neural Networks: Zero To Hero](https://karpathy.ai/zero-to-hero.html) course.\n\n## Installation\n\n```\ngem install micrograd\n```\n\n## Usage\n\nHere are some of the operatinos available on `Value`.\n\n\n```ruby\ninclude Micrograd\n\na = Value.new(2.0)\nb = Value.new(-3.0)\nc = Value.new(10.0)\ne = a * b\nd = e + c\nf = Value.new(-2.0)\n\nl = d * f\n\n# Walk through all the values and calculate gradients for them.\nl.start_backward\n```\n\nExample of training a multi level perceptron (`MLP`):\n\n\n```ruby\nmlp = MLP.new(input_size: 3, layer_sizes: [4, 4, 1])\n\n# These are the training inputs\ninputs = [\n  [2.0, 3.0, -1.0],\n  [3.0, -1.0, 0.5],\n  [0.5, 1.0, 1.0],\n  [1.0, 1.0, -1.0],\n]\n\n# These are the outputs for each of the inputs above.\ndesired_outputs = [1.0, -1.0, -1.0, 1.0]\n\n# Training loop\n100.times do |n|\n  # forward pass\n  mlp_outputs = inputs.map { mlp.call(_1).first }\n  loss = desired_outputs.zip(mlp_outputs).sum { (_1 - _2) ** 2 }\n\n  # backward pass\n  mlp.parameters.each { _1.grad = 0.0 }\n  loss.start_backward\n\n  # update the params\n  mlp.parameters.each { _1.data -= _1.grad * 0.1 }\nend\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/nithinbekal/micrograd. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/nithinbekal/micrograd/blob/main/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Micrograd project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/nithinbekal/micrograd/blob/main/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnithinbekal%2Fmicrograd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnithinbekal%2Fmicrograd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnithinbekal%2Fmicrograd/lists"}