{"id":26517609,"url":"https://github.com/borjaest/nnet","last_synced_at":"2025-07-17T14:33:23.525Z","repository":{"id":71556055,"uuid":"266814552","full_name":"BorjaEst/nnet","owner":"BorjaEst","description":"Neural networks representation in erlang","archived":false,"fork":false,"pushed_at":"2020-08-04T08:22:17.000Z","size":688,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-21T08:32:52.687Z","etag":null,"topics":["erlang","machine-learning","neural-network","representation"],"latest_commit_sha":null,"homepage":"","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BorjaEst.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-25T15:28:08.000Z","updated_at":"2023-04-11T13:08:43.000Z","dependencies_parsed_at":"2023-03-07T05:45:39.959Z","dependency_job_id":null,"html_url":"https://github.com/BorjaEst/nnet","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/BorjaEst/nnet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorjaEst%2Fnnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorjaEst%2Fnnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorjaEst%2Fnnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorjaEst%2Fnnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BorjaEst","download_url":"https://codeload.github.com/BorjaEst/nnet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorjaEst%2Fnnet/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265616727,"owners_count":23798879,"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":["erlang","machine-learning","neural-network","representation"],"created_at":"2025-03-21T08:27:46.577Z","updated_at":"2025-07-17T14:33:23.520Z","avatar_url":"https://github.com/BorjaEst.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Erlang Neural Networks (nnet) is an application to represent neural networks in erlang terms.\n\n\n# Installation\nCreate your own project with rebar3.\n ```sh\n $ rebar3 new app yourapp\n ```\n\nThen in your project path find rebar.config file and add nnet as dependency under the deps key:\n```erlang\n{deps, \n    [\n        {nnet, {git, \"https://github.com/BorjaEst/nnet.git\", {tag, \"\u003cversion\u003e\"}}}\n    ]}.\n```\n\nThen using compile command, rebar3 will fetch the defined dependencies and compile them as well for your application.\n```sh\n$ rebar3 compile\n```\n\nAt the end for making a release you first need to create your release structure and then making a release with following commands.\n```sh\n$ rebar3 new release yourrel\n$ rebar3 release\n```\n\n\u003eYou can find more information about dependencies in [rebar3 - dependencies](https://www.rebar3.org/docs/dependencies). \n\n\n# Usage\nLoad the app using your prefered method. For example in the project folder executing  rebar3 shell:\n```sh\n$ rebar3 shell\n===\u003e Booted nnet\n```\n\nAll user functions are defined inside the module [src/nnet](https://github.com/BorjaEst/nnet/blob/master/src/nnet.erl), however here is an example:\n\n\n## Start tables\nAs library without OTP supervision tree, the best way to start is to ensure the tables are created. \n```erl\n1\u003e nnet:start_tables().\nok\n```\n\u003e The function will not fail if the tables are already created and correct.\n\n## Create a network from a model\nTo create a network from a model it is very easy. Just create a map where each layer is a key (inputs \u0026 outputs are mandatory) and the values are:\n- \"connections\": Type of connection and density between layers.\n- \"units\": The amount of neurons on each layer.\n- \"data\": The information on each node on each layer.\n\n```erl\n2\u003e M = #{inputs  =\u003e #{connections =\u003e #{\n2\u003e                    layer1  =\u003e sequential,\n2\u003e                    layer2  =\u003e {sequential,0.5}}, \n2\u003e                   units =\u003e 2, data=\u003e#{}},\n2\u003e       layer1  =\u003e #{connections =\u003e #{\n2\u003e                    layer2  =\u003e sequential,\n2\u003e                    outputs =\u003e {sequential,0.5}}, \n2\u003e                   units =\u003e 4, data=\u003e#{}},\n2\u003e       layer2  =\u003e #{connections =\u003e #{\n2\u003e                    layer2  =\u003e recurrent,\n2\u003e                    outputs =\u003e sequential}, \n2\u003e                   units =\u003e 4, data=\u003e#{}},\n2\u003e       outputs =\u003e #{connections =\u003e #{\n2\u003e                    inputs  =\u003e {recurrent, 0.5},\n2\u003e                    layer2  =\u003e recurrent}, \n2\u003e                   units =\u003e 2, data=\u003e#{}}}.\n...\n3\u003e {atomic,Id} = mnesia:transaction(fun() -\u003e nnet:from_model(M) end)\n{atomic,{network,#Ref\u003c0.1530882211.2808086529.180929\u003e}}\n```\n\n## Get the network nodes, inputs and outputs\nUsing the function `nnet:to_map/1` you can retrieve the network data.\n```erl\n4\u003e mnesia:transaction(fun() -\u003e nnet:to_map(Id) end).\n{atomic,#{{network,#Ref\u003c0.1530882211.2808086529.180929\u003e} =\u003e\n              [{{network,#Ref\u003c0.1530882211.2808086529.180929\u003e},\n                {nnode,#Ref\u003c0.1530882211.2808086529.180893\u003e}},\n               {{network,#Ref\u003c0.1530882211.2808086529.180929\u003e},\n                {nnode,#Ref\u003c0.1530882211.2808086529.180896\u003e}}],\n          {nnode,#Ref\u003c0.1530882211.2808086529.180893\u003e} =\u003e\n              [{{nnode,#Ref\u003c0.1530882211.2808086529.180893\u003e},\n                {nnode,#Ref\u003c0.1530882211.2808086529.180899\u003e}},\n               {{nnode,#Ref\u003c0.1530882211.2808086529.180893\u003e},\n                {nnode,#Ref\u003c0.1530882211.2808086529.180902\u003e}},\n               {{nnode,#Ref\u003c0.1530882211.2808086529.180893\u003e},\n                {nnode,#Ref\u003c0.1530882211.2808086529.180905\u003e}},\n               {{nnode,#Ref\u003c0.1530882211.2808086529.180893\u003e},\n                {nnode,#Ref\u003c0.1530882211.2808086529.180908\u003e}},\n               {{nnode,#Ref\u003c0.1530882211.2808086529.180893\u003e},\n                {nnode,#Ref\u003c0.1530882211.2808086529.180911\u003e}},\n               {{nnode,#Ref\u003c0.1530882211.2808086529.180893\u003e},\n                {nnode,#Ref\u003c0.1530882211.2808086529.180914\u003e}}],\n...\n          {nnode,#Ref\u003c0.1530882211.2808086529.180926\u003e} =\u003e\n              [{{nnode,#Ref\u003c0.1530882211.2808086529.180926\u003e},\n                {network,#Ref\u003c0.1530882211.2808086529.180929\u003e}}]}}\n```\n\u003e Note the network inputs are out(Network): Network -\u003e NNode\n\n\u003e Note the network outputs are in(Network):   NNode -\u003e Network\n\n\n## Get a nnode inputs and outputs\nAfter a network is create, you can modify it using the functions:\n```erl\n%% NNode operations (run inside 'fun edit/1') \n-export([rnode/1, wnode/2, rlink/1, wlink/2]).\n-export([out/1, out_seq/1, out_rcc/1, in/1, lx/1]).\n%% Connections operations (run inside 'fun edit/1')\n-export([connect/1, connect_seq/1, connect_rcc/1, disconnect/1]).\n-export([move/2, reset/1]).\n%% Network operations (run inside 'fun edit/1')\n-export([copy/2, clone/2, divide/2, split/2, delete/2, join/2]).\n```\n\n\n# Visualization\nThere is a secret (not so secret) module \"umlnn\" which prints/formats the neural network in UML format (components diagram).\nYou can use the results of that function together with [plantUML](http://www.plantuml.com/plantuml/uml) to display your nerwork.\n\nTo display the sequential connections use the output from: `umlnn:print_seq(Network_id)`\n\n![Image of sequential connections](doc/src/nnet_seq.png)\n\nTo display the recurrent connections use the output from: `umlnn:print_rcc(Network_id)`\n\n![Image of recurrent connections](doc/src/nnet_rcc.png)\n\n\n# More examples\nInside the module **./src/nnet.erl** you will find the spec and comments for each function. Note that most of the functions are mnesia transactions therefore should run inside a `mnesia:transaction/1` context.\n\nFor examples of usage you can take a look on the test suite **./test/nnet_SUITE.erl**.\n\n\n# Contributing\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n\n\n## Improvement ideas and requests\nAll ideas and sugestions are welcome:\n- \u003cTBD\u003e\n\n\n\n# License\nThis software is under [GPL-3.0](https://www.gnu.org/licenses/gpl-3.0.en.html) license.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborjaest%2Fnnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fborjaest%2Fnnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborjaest%2Fnnet/lists"}