{"id":51113955,"url":"https://github.com/acctress/znn","last_synced_at":"2026-06-24T20:01:19.454Z","repository":{"id":361955893,"uuid":"1256599731","full_name":"acctress/znn","owner":"acctress","description":"A neural network written from scratch in Zig","archived":false,"fork":false,"pushed_at":"2026-06-02T00:10:35.000Z","size":41549,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-02T02:12:20.843Z","etag":null,"topics":["ai","neural-network","zig"],"latest_commit_sha":null,"homepage":"","language":"Zig","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/acctress.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-01T23:44:57.000Z","updated_at":"2026-06-02T00:10:38.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/acctress/znn","commit_stats":null,"previous_names":["acctress/znn"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/acctress/znn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acctress%2Fznn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acctress%2Fznn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acctress%2Fznn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acctress%2Fznn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acctress","download_url":"https://codeload.github.com/acctress/znn/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acctress%2Fznn/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34747387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-24T02:00:07.484Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":["ai","neural-network","zig"],"created_at":"2026-06-24T20:01:18.750Z","updated_at":"2026-06-24T20:01:19.448Z","avatar_url":"https://github.com/acctress.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# znn\nA simple neural network written from scratch in Zig\n\n# Under the Hood\nIn znn, the network is built with multiple `Layer`s. They store weights and biases as flat float arrays, they have two methods - forward and backward.\nForward computes a weighted sum of inputs with bias added with ReLU activation for the hidden layers and linear activation for output layers.\n\nThe `Network` struct chains the layers. Buffers are preallocated for efficiency and they pass data between layers, `forward` feeds output of each layer into the next.\n\nCool thing is, this network can actually learn (🤯). The way it works is that given an expected output, it computes how wrong each weight was and nudges them into the right direction using gradient descent.\n\nThe learning was proved by running `forward` and `backward` repeatedly until the network converges towards the target, it starts at a random guess and reaches the target within 1000 iterations.\n\n![img.png](img.png)\n\nI ran a 5 million iteration training stage on the network to learn multiplication, here is what it done:\n\n![img_3.png](img_3.png)\n\nIt's okay, but very impressive for the size of the architecture.\n\nI tested XOR to ensure training was actually happening. I ran i through three inputs and expected results:\n![img_1.png](img_1.png)\n\nSo that's: `0 xor 1 = 1`, `1 xor 0 = 1`, `1 xor 1 = 0`. And the results are successful:\n\n![img_2.png](img_2.png)\n\nIt learnt to XOR without me telling it to do so after 100,000 iterations.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facctress%2Fznn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facctress%2Fznn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facctress%2Fznn/lists"}