{"id":16314456,"url":"https://github.com/mikhailkravets/neuroflow","last_synced_at":"2025-04-07T07:07:51.677Z","repository":{"id":43212952,"uuid":"95146282","full_name":"MikhailKravets/NeuroFlow","owner":"MikhailKravets","description":"Awesome deep learning crate","archived":false,"fork":false,"pushed_at":"2023-08-18T07:34:39.000Z","size":187,"stargazers_count":117,"open_issues_count":0,"forks_count":20,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-31T05:07:19.571Z","etag":null,"topics":["backpropagation","deep-learning","machine-learning","neural-network","neural-network-rust","nn","rust"],"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/MikhailKravets.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2017-06-22T18:45:50.000Z","updated_at":"2025-01-09T15:49:18.000Z","dependencies_parsed_at":"2022-09-08T16:51:12.911Z","dependency_job_id":"6f4a4405-8c36-4397-ad4c-4d0fd1cdd682","html_url":"https://github.com/MikhailKravets/NeuroFlow","commit_stats":{"total_commits":186,"total_committers":2,"mean_commits":93.0,"dds":0.005376344086021501,"last_synced_commit":"7896e13a38956b16d136f587cce073d147600e35"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikhailKravets%2FNeuroFlow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikhailKravets%2FNeuroFlow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikhailKravets%2FNeuroFlow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikhailKravets%2FNeuroFlow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MikhailKravets","download_url":"https://codeload.github.com/MikhailKravets/NeuroFlow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247608151,"owners_count":20965952,"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":["backpropagation","deep-learning","machine-learning","neural-network","neural-network-rust","nn","rust"],"created_at":"2024-10-10T21:53:59.846Z","updated_at":"2025-04-07T07:07:51.649Z","avatar_url":"https://github.com/MikhailKravets.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/MikhailKravets/NeuroFlow/master/logo.png\"\u003e\u003cbr\u003e\u003cbr\u003e\n\u003c/div\u003e\n\n[![codecov](https://codecov.io/gh/MikhailKravets/NeuroFlow/branch/master/graph/badge.svg)](https://codecov.io/gh/MikhailKravets/NeuroFlow)\n[![crates](https://img.shields.io/crates/v/neuroflow.svg)](https://crates.io/crates/neuroflow)\n\n\u003e NeuroFlow is fast Neural Networks (deep learning) Rust crate.\n\u003e It relies on three pillars: speed, reliability, and speed again.\n\n...I would write if this library was going to be the second PyTorch from the Rust world.\nHowever, this repository found its place in the educational area and can be\nused by young Rustaceans to enter the world of Neural Networks.\n\n## How to use\n\nLet's try to approximate a very simple function `0.5*sin(e^x) - cos(e^(-x))`.\n\n```rust\nextern crate neuroflow;\n\nuse neuroflow::FeedForward;\nuse neuroflow::data::DataSet;\nuse neuroflow::activators::Type::Tanh;\n\n\nfn main(){\n    /*\n        Define a neural network with 1 neuron in input layers. The network contains 4 hidden layers.\n        And, such as our function returns a single value, it is reasonable to have 1 neuron in the output layer.\n    */\n    let mut nn = FeedForward::new(\u0026[1, 7, 8, 8, 7, 1]);\n    \n    /*\n        Define DataSet.\n        \n        DataSet is the Type that significantly simplifies work with neural networks.\n        The majority of its functionality is still under development :(\n    */\n    let mut data: DataSet = DataSet::new();\n    let mut i = -3.0;\n    \n    // Push the data to DataSet (method push accepts two slices: input data and expected output)\n    while i \u003c= 2.5 {\n        data.push(\u0026[i], \u0026[0.5*(i.exp().sin()) - (-i.exp()).cos()]);\n        i += 0.05;\n    }\n    \n    // Here, we set the necessary parameters and train the neural network by our DataSet with 50 000 iterations\n    nn.activation(Tanh)\n        .learning_rate(0.01)\n        .train(\u0026data, 50_000);\n\n    let mut res;\n    \n    // Let's check the result\n    i = 0.0;\n    while i \u003c= 0.3{\n        res = nn.calc(\u0026[i])[0];\n        println!(\"for [{:.3}], [{:.3}] -\u003e [{:.3}]\", i, 0.5*(i.exp().sin()) - (-i.exp()).cos(), res);\n        i += 0.07;\n    }\n}\n```\n\nExpected output\n```\nfor [0.000], [-0.120] -\u003e [-0.119]\nfor [0.070], [-0.039] -\u003e [-0.037]\nfor [0.140], [0.048] -\u003e [0.050]\nfor [0.210], [0.141] -\u003e [0.141]\nfor [0.280], [0.240] -\u003e [0.236]\n```\n\nBut we don't want to lose our trained network so easily. So, there is functionality to save and restore\nneural networks from files.\n\n```rust\n\n    /*\n        In order to save neural network into file call function save from neuroflow::io module.\n        \n        The first argument is the link to the saving neural network;\n        The second argument is the path to the file. \n    */\n    neuroflow::io::save(\u0026mut nn, \"test.flow\").unwrap();\n    \n    /*\n        After we have saved the neural network to the file we can restore it by calling\n        of load function from neuroflow::io module.\n        \n        We must specify the type of new_nn variable.\n        The only argument of the load function is the path to a file containing\n        the neural network\n    */\n    let mut new_nn: FeedForward = neuroflow::io::load(\"test.flow\").unwrap();\n```\n\n----------------------\n\nClassic XOR problem (with no classic input of data)\n\nLet's create a file named `TerribleTom.csv` at the root of the project. This file should have the following innards:\n\n```\n0,0,-,0\n0,1,-,1\n1,0,-,1\n1,1,-,0\n```\n\nwhere `-` is the delimiter that separates the input vector from its desired output vector.\n\n```rust\nextern crate neuroflow;\n\nuse neuroflow::FeedForward;\nuse neuroflow::data::DataSet;\nuse neuroflow::activators::Type::Tanh;\n\n\nfn main(){\n    /*\n        Define a neural network with 2 neurons in input layers,\n        1 hidden layer (with 2 neurons),\n        1 neuron in the output layer\n    */\n    let mut nn = FeedForward::new(\u0026[2, 2, 1]);\n    \n    // Here we load data for XOR from the file `TerribleTom.csv`\n    let mut data = DataSet::from_csv(\"TerribleTom.csv\");\n    \n    // Set parameters and train the network\n    nn.activation(Tanh)\n        .learning_rate(0.1)\n        .momentum(0.15)\n        .train(\u0026data, 20_000);\n\n    let mut res;\n    let mut d;\n    for i in 0..data.len(){\n        res = nn.calc(data.get(i).0)[0];\n        d = data.get(i);\n        println!(\"for [{:.3}, {:.3}], [{:.3}] -\u003e [{:.3}]\", d.0[0], d.0[1], d.1[0], res);\n    }\n}\n```\nExpected output\n```\nfor [0.000, 0.000], [0.000] -\u003e [0.000]\nfor [1.000, 0.000], [1.000] -\u003e [1.000]\nfor [0.000, 1.000], [1.000] -\u003e [1.000]\nfor [1.000, 1.000], [0.000] -\u003e [0.000]\n```\n\n## Installation\nInsert into your project's cargo.toml block next line\n```toml\n[dependencies]\nneuroflow = \"~0.2\"\n```\n\nThen in project root file\n```rust\nextern crate neuroflow;\n```\n\n## License\nMIT License\n\n### Attribution\nThe origami bird from the logo is made by [Freepik](https://www.freepik.com/)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikhailkravets%2Fneuroflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikhailkravets%2Fneuroflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikhailkravets%2Fneuroflow/lists"}