{"id":18004288,"url":"https://github.com/gigasquid/k9","last_synced_at":"2025-03-26T10:31:19.521Z","repository":{"id":140526790,"uuid":"14124261","full_name":"gigasquid/k9","owner":"gigasquid","description":"Small library for using neural networks and core.matrix","archived":false,"fork":false,"pushed_at":"2015-02-20T13:03:50.000Z","size":195,"stargazers_count":104,"open_issues_count":0,"forks_count":13,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-05-02T07:40:37.736Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Clojure","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/gigasquid.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}},"created_at":"2013-11-04T21:36:42.000Z","updated_at":"2023-12-04T08:31:44.000Z","dependencies_parsed_at":"2023-03-13T10:41:41.692Z","dependency_job_id":null,"html_url":"https://github.com/gigasquid/k9","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/gigasquid%2Fk9","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gigasquid%2Fk9/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gigasquid%2Fk9/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gigasquid%2Fk9/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gigasquid","download_url":"https://codeload.github.com/gigasquid/k9/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222137923,"owners_count":16937415,"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":[],"created_at":"2024-10-30T00:13:57.858Z","updated_at":"2024-10-30T00:13:57.916Z","avatar_url":"https://github.com/gigasquid.png","language":"Clojure","funding_links":[],"categories":["Machine Learning"],"sub_categories":[],"readme":"# k9\n\nA small library using core.matrix to construct Neural Networks\n\n## Usage\n\nConstruct simple 3 layer networks with\n\n```clojure\n(construct-network n-inputs n-hiddens n-ouputs)\n```\nExample\n```clojure\n(construct-network 2 3 2)\n;=\u003e [ [0 0] [input-to-hidden-strengths] [0 0 0] [hidden-to-output-strengths] [0 0]]\n```\n\nFeed foward input and get back output neuron values with\n```clojure\n(ff input network)\n```\n\nExample\n```clojure\n(ff [1 0] (construct-network 2 3 2));=\u003e[0.023969361623158485 0.014886788800864243]\n```\n\nTrain the network on data in the form of [[input target]\n[input target] ... ] =\u003e returns a new network\n\n```clojure\n(train-data network data learning-rate)\n```\n\nExample\n```clojure\n(def nn (construct-network 2 3 2))\n#'user/nn\n;; without training\n(ff [1 0] nn) ;=\u003e [0.03061049829949632 0.043037351551821625]\n(def n1 (train-data nn  [\n                         [[1 0] [0 1]]\n                         [[0.5 0] [0 0.5]]\n                         [[0.25 0] [0 0.25]]]\n                     0.2))\n(ff [1 0] n1) \n;=\u003e [0.0383350329723964 0.06845383345543034]\n````\n\nAnother example\n```clojure\n(defn inverse-data []\n  (let [n (rand 1)]\n    [[n 0] [0 n]]))\n\n(def n3 (train-data nn (repeatedly 400 inverse-data) 0.5))\n\n(ff [1 0] n3) ;=\u003e [-3.0872502374300364E-4 0.8334331107408276]\n````\n\nCan also train the network repeatedly on a set of data for \"epochs\"\n```clojure\n(train-epochs n network training-data learning-rate)\n```\n\nExample\n```clojure\n(def n4 (train-epochs 5 nn (repeatedly 200 inverse-data) 0.2))\n(ff [1 0] n4) ;=\u003e [-3.794899940782748E-4 0.8105184486966243\n```\n\n## Example with Colors\nThere is another example in the examples directory where the network learns to name colors based on their rgb value.\n\n## Blog Post\nI made a blog post about making a simple neural network with an example\nhere:\n[Blog](http://gigasquidsoftware.com/blog/2013/12/02/neural-networks-in-clojure-with-core-dot-matrix/)\n\n\n## License\n\nCopyright © 2013 Carin Meier\n\nDistributed under the Eclipse Public License, the same as Clojure\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgigasquid%2Fk9","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgigasquid%2Fk9","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgigasquid%2Fk9/lists"}