{"id":32386099,"url":"https://github.com/patricksongzy/corgi","last_synced_at":"2025-10-25T02:57:09.741Z","repository":{"id":62439020,"uuid":"304507836","full_name":"patricksongzy/corgi","owner":"patricksongzy","description":"A neural network, and tensor dynamic automatic differentiation implementation for Rust.","archived":false,"fork":false,"pushed_at":"2024-12-11T03:49:11.000Z","size":926,"stargazers_count":24,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-24T12:54:25.073Z","etag":null,"topics":["autograd","deep-learning","machine-learning","neural-network","rust","tensor"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/patricksongzy.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}},"created_at":"2020-10-16T03:19:24.000Z","updated_at":"2025-05-09T23:15:56.000Z","dependencies_parsed_at":"2022-11-01T21:50:07.444Z","dependency_job_id":null,"html_url":"https://github.com/patricksongzy/corgi","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/patricksongzy/corgi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patricksongzy%2Fcorgi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patricksongzy%2Fcorgi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patricksongzy%2Fcorgi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patricksongzy%2Fcorgi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patricksongzy","download_url":"https://codeload.github.com/patricksongzy/corgi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patricksongzy%2Fcorgi/sbom","scorecard":{"id":722479,"data":{"date":"2025-08-11","repo":{"name":"github.com/patricksongzy/corgi","commit":"721510f678c58105a7d285d5cfdbba6cdf88d351"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/rust.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/rust.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/patricksongzy/corgi/rust.yml/main?enable=pin","Info:   0 out of   1 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'","Warn: branch protection not enabled for branch 'release'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-22T11:47:16.230Z","repository_id":62439020,"created_at":"2025-08-22T11:47:16.232Z","updated_at":"2025-08-22T11:47:16.232Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280897679,"owners_count":26409960,"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-10-25T02:00:06.499Z","response_time":81,"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":["autograd","deep-learning","machine-learning","neural-network","rust","tensor"],"created_at":"2025-10-25T02:57:08.050Z","updated_at":"2025-10-25T02:57:09.732Z","avatar_url":"https://github.com/patricksongzy.png","language":"Rust","funding_links":[],"categories":["Rust","Machine Learning"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eCorgi\u003c/h1\u003e\n\u003cp align=\"center\"\u003eA neural network, and tensor dynamic automatic differentiation implementation for Rust.\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/patricksongzy/corgi/\"\u003e\n        \u003cimg alt=\"Build: Github Workflow\" src=\"https://img.shields.io/github/workflow/status/patricksongzy/corgi/Rust\"\u003e\u003c/img\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://crates.io/crates/corgi\"\u003e\n        \u003cimg alt=\"Download: crates.io\" src=\"https://img.shields.io/crates/v/corgi\"\u003e\u003c/img\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://docs.rs/corgi\"\u003e\n        \u003cimg alt=\"Documentation: docs.rs\" src=\"https://docs.rs/corgi/badge.svg\"\u003e\u003c/img\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/patricksongzy/corgi/blob/main/LICENSE\"\u003e\n        \u003cimg alt=\"Licence: MIT\" src=\"https://img.shields.io/badge/license-MIT-blue.svg\"\u003e\u003c/img\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\u003chr\u003e\n\n```rust\nlet l1 = Dense::new(input_size, hidden_size, \u0026initializer, Some(\u0026relu));\nlet l2 = Dense::new(hidden_size, output_size, \u0026initializer, Some(\u0026softmax));\nlet mut model = Model::new(vec![\u0026mut l1, \u0026mut l2], \u0026gradient_descent, \u0026cross_entropy);\n\nfor _ in 0..iterations {\n    // array operations are never in-place for corgi, so values never change\n    let input = Array::from((vec![batch_size, input_size], vec![...]));\n    let target = Array::from((vec![batch_size, output_size], vec![...]));\n\n    let _result = model.forward(input);\n    let loss = model.backward(target);\n    // update the parameters, and clear gradients (backward pass only sets gradients)\n    model.update();\n\n    println!(\"loss: {}\", loss);\n}\n```\n\n## Design\n* Array operations are never in-place, meaning array values are never modified.\n* Eager execution.\n* Dynamic-as-possible computational graph.\n```rust\nfor _ in 0..10 {\n    c = \u0026c + \u0026(\u0026a * \u0026b);\n    if c[0] \u003e 50.0 {\n        c = \u0026c * \u0026a;\n    }\n}\n\nc.backward(None);\n```\n* The Array is responsible differentiates operations done on it for the backward pass.\n* No graph structure for ergonomics - an `Array` contains only its children.\n* Arrays do note store consumers (at the moment). They store consumer counts instead.\n\n## BLAS\n* The `openblas`, or `netlib` features can be enabled.\n* Versions prior to 0.9.7 of Corgi did not prioritise optimisation, and will be slow.\n\n### Tracked Arrays\n* Arrays are untracked by default, so if gradients are required, `tracked()`, or `start_tracking()` must be used (see the documentation for details).\n* Tracked arrays are arrays which require gradients to be computed, and stored.\n* For more information, see the documentation for `tracked()`, and `untracked()` in `array.rs`.\n\n## Examples\n* Fully-connected neural network ([full version](https://github.com/patricksongzy/corgi/blob/main/src/model.rs#L221)):\n```rust\nlet initializer = initializer::he();\nlet relu = activation::relu();\nlet softmax = activation::softmax();\nlet ce = cost::cross_entropy();\nlet gd = GradientDescent::new(learning_rate);\nlet l1 = Dense::new(input_size, hidden_size, \u0026initializer, Some(\u0026relu));\nlet l2 = Dense::new(hidden_size, output_size, \u0026initializer, Some(\u0026softmax));\nlet mut model = Model::new(vec![\u0026mut l1, \u0026mut l2], \u0026gd, \u0026ce);\n\nfor _ in 0..iterations {\n    let mut input = vec![0.0; input_size * batch_size];\n    let mut target = vec![0.0; output_size * batch_size];\n\n    // set inputs, and targets\n\n    // arrays in corgi should not be mutated after creation, so we initialise the values first\n    let input = Array::from((vec![batch_size, input_size], input));\n    let target = Array::from((vec![batch_size, output_size], target));\n\n    let _result = model.forward(input);\n    let loss = model.backward(target);\n    // update the parameters, and clear gradients (backward pass only sets gradients)\n    model.update();\n\n    println!(\"loss: {}\", loss);\n}\n```\n* Dynamic computational graph:\n```rust\nlet a = arr![5.0].tracked();\nlet b = arr![2.0].tracked();\nlet mut c = arr![0.0].tracked();\n\nfor _ in 0..10 {\n    c = \u0026c + \u0026(\u0026a * \u0026b);\n    if c[0] \u003e 50.0 {\n        c = \u0026c * \u0026a;\n    }\n}\n\nassert_eq!(c, arr![195300.0]);\n\nc.backward(None);\nassert_eq!(c.gradient(), arr![1.0]);\nassert_eq!(b.gradient(), arr![97650.0]);\nassert_eq!(a.gradient(), arr![232420.0]);\n```\n* [Custom operation](https://github.com/patricksongzy/corgi/blob/main/src/lib.rs#L34) (still needs some work).\n\n## Resources\n* Shields are from [shields.io](https://shields.io).\n* MIT 6.034 on OpenCourseWare for a primer on Backward Propagation.\n* CS231n YouTube recordings for a primer on Convolutional Neural Networks.\n\nA lot of the library was built around being as dynamic as possible, meaning if chosen well, some design choices might be similar to other dynamic computational graph libraries.\n\nThird-party libraries were used, and can be found in `Cargo.toml`.\n\n## Licence\n* MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatricksongzy%2Fcorgi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatricksongzy%2Fcorgi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatricksongzy%2Fcorgi/lists"}