{"id":26517613,"url":"https://github.com/borjaest/enn","last_synced_at":"2026-03-07T06:02:20.249Z","repository":{"id":71556032,"uuid":"202397091","full_name":"BorjaEst/enn","owner":"BorjaEst","description":"Artificial Neural Network (ANN) based on Erlang language","archived":false,"fork":false,"pushed_at":"2020-10-04T08:55:51.000Z","size":464,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-19T19:00:41.998Z","etag":null,"topics":["artificial-intelligence","elixir","erlang","machine-learning","neural-network","neural-networks"],"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":"2019-08-14T17:33:31.000Z","updated_at":"2023-04-12T01:37:04.000Z","dependencies_parsed_at":"2023-05-10T16:15:27.766Z","dependency_job_id":null,"html_url":"https://github.com/BorjaEst/enn","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/BorjaEst/enn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorjaEst%2Fenn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorjaEst%2Fenn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorjaEst%2Fenn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorjaEst%2Fenn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BorjaEst","download_url":"https://codeload.github.com/BorjaEst/enn/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorjaEst%2Fenn/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30208801,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T05:23:27.321Z","status":"ssl_error","status_checked_at":"2026-03-07T05:00:17.256Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["artificial-intelligence","elixir","erlang","machine-learning","neural-network","neural-networks"],"created_at":"2025-03-21T08:27:47.227Z","updated_at":"2026-03-07T06:02:20.240Z","avatar_url":"https://github.com/BorjaEst.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# enn\nErlang Neural Networks (enn) is an application to implement artificial inteligence based on artificial neural networks (ANN).\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 enn as dependency under the deps key:\n```erlang\n{deps, \n    [\n        {enn, {git, \"https://github.com/BorjaEst/enn.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 enn\n```\n\n\nAll user functions are defined inside the module [src/enn](https://github.com/BorjaEst/enn/blob/master/src/enn.erl), however here is an example:\n\n\n\n### Measure performance and resources\nFirst of all I woudl initialize the observer, so you can see the loads of the \nsystem and the ETS tables:\n```erl\n1\u003e observer:start().\nok\n```\n\u003e Here you can find a table nn_pool with all the currently enabled neural netwroks.\n\n### Define and start your erlang neural network\nYou can create a neural network simply with enn:start/1:\n```erl\n2\u003e Network = enn:start(\n2\u003e     #{inputs  =\u003e layer:input(2, #{hidden1 =\u003e sequential}),\n2\u003e       hidden1 =\u003e layer:sigmoid(4, #{hidden2 =\u003e sequential}),\n2\u003e       hidden2 =\u003e layer:dense(3, #{outputs =\u003e sequential}),\n2\u003e       outputs =\u003e layer:output(2, #{})}).\n{network,#Ref\u003c0.367976965.4190896130.201756\u003e}\n```\n\u003e It is important to save the \"Network id\", you will need it to stop the network.\n\nAnother option is to first compile the model and run it after in 2 steps:\n```erl\n2\u003e {atomic, Network} = mnesia:transaction(\n2\u003e     fun() -\u003e nnet:compile(\n2\u003e         #{inputs  =\u003e layer:input(2, #{hidden1 =\u003e sequential}),\n2\u003e           hidden1 =\u003e layer:sigmoid(4, #{hidden2 =\u003e sequential}),\n2\u003e           hidden2 =\u003e layer:dense(3, #{outputs =\u003e sequential}),\n2\u003e           outputs =\u003e layer:output(2, #{})})\n2\u003e     end).\n{atomic,{network, #Ref\u003c0.367976965.4190896130.204258\u003e}}\n3\u003e Network = enn:start(Network).\n{network,#Ref\u003c0.367976965.4190896130.204258\u003e}\n```\n\n### Generate/load your training data\nThen you should gerenate your training, for example:\n```erl\n3\u003e Loops  = 8000,\n3\u003e Inputs = [[rand:uniform()-0.5, rand:uniform()-0.5] || _ \u003c- lists:seq(1, Loops)],\n3\u003e Optima = [[I1+I2, I1-I2] || [I1, I2] \u003c- Inputs],\n3\u003e ok.\nok\n```\n\n### Train your neural network\nThis operation is done by enn:fit/3:\n```erl\n4\u003e enn:fit(Network, Inputs, Optima),\n4\u003e ok.\n800     [==\u003e.................]  loss:   0.5324397056244214      \n1600    [====\u003e...............]  loss:   0.4869926512788517      \n2400    [======\u003e.............]  loss:   0.4189957818517215      \n3200    [========\u003e...........]  loss:   0.3559475178487766      \n4000    [==========\u003e.........]  loss:   0.3010031908365078      \n4800    [============\u003e.......]  loss:   0.2503973090555499      \n5600    [==============\u003e.....]  loss:   0.1866318856840655      \n6400    [================\u003e...]  loss:   0.1127141419963432      \n7200    [==================\u003e.]  loss:   0.0537037399650812      \n8000    [====================]  loss:   0.0284808195771375      \nok\n```\n\n### Do some predictions\nThis operation is done by enn:predict/2:\n```erl\n5\u003e enn:predict(Network, [\n5\u003e      [0.1, 0.6],\n5\u003e      [0.3, 0.2],\n5\u003e      [0.1, 0.1]\n5\u003e ]).\n[[0.6172463551362715, -0.47078835817371445 ],\n [0.49594263285192497, 0.0965897828109617  ],\n [0.21946863843177294,-0.010693899601060347]]\n```\n\n\u003e For more options such log the cycles, or do not do not print the results, explore the options in the function enn:run/4. \n\n\n### Stop your neural network\nYou can easily do it with enn:stop/1:\n```erl\n6\u003e enn:stop(Network).\nok\n```\nYou will see in the observer window the network is gone.\n\u003e You can resume your network with enn:start/1, the last network status is saved!\n\n\n### Clone your work into a different network\nJust call enn:clone/1\n```erl\n7\u003e {atomic, Clone_id} = mnesia:transaction(fun() -\u003e nnet:clone(Network) end).\n{atomic,{network,#Ref\u003c0.3730030165.1951137794.240054\u003e}}\n```\n\n\n### Resume your neural network\nRestart the network with enn:start/1:\n```erl\n8\u003e enn:start(Network),\n8\u003e enn:predict(Network, [\n8\u003e     [0.1, 0.6],\n8\u003e     [0.3, 0.2],\n8\u003e     [0.1, 0.1]\n8\u003e ]).\n[[0.6172463551362715, -0.47078835817371445 ],\n [0.49594263285192497, 0.0965897828109617  ],\n [0.21946863843177294,-0.010693899601060347]]]\n```\n\n\n## Examples\nThe folder test includes a module *test_architectures.erl* where you can find a lot of useful examples of models. Feel free to propose yours.\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\nIn progress:\n- Momentum, not well implemented on enn, review. This helps a lot when not using batch normalisation.\n- Boolean activation function.\n- Try which derivade behaves better (and if can be common to some activations).\n\nErlang performance:\n- Use binary for long messages to speedup communications.\n- Runtime connections change: ETS table with connections [{{in,N2},N1}, {{out,N1},N2}]\n\nSpeed-up training:\n- ELU activation function seems by papers to perform better than Sigmoid and ReLU. Leaky ReLU is good as well.\n\nFind correct solution:\n- none for now\n\n\nImportants to be clasified:\n- Normalisation: Batch normalisation\n- Regularization: dropout\n- Optimizer: Adam\n- Learning rate schedule: None\n- Dropout, every training step (except output neurons) has a probability to be ignored during that training step. The weights have to be multiplied by this factor after training.\n- Play with learning rate:\n    - After some trainings, reduce the value a defined value\n    - Reduce if the error grows / Proportional to error\n    - Exponential reduction\n    - Power scheduling\n- Weights close to 0 must be set to 0, so in the next construction are removed\n- Implement optimisers:\n    -Nesterov Accelerated Gradient, performs better than momentum\n    -AdaGrad, good idea but not efficient on the last steps\n    -RMSProp, improvement of AdaGrad\n    -Adam Optimization, adaptative moment estimation. This is the best in almost all cases.\n\n\nNice to try:\n- New Input attribute; Correlation, measures how much the input changed in relation with the error. For example a neuron with inputs A,B,C but optima is A+B, C would have a \"correlation\" near to 0 and should be deleted.\n\n- Residual Network?, add a transfer function to the activation function to make it time dependent\n- Max-Norm regularisation,.      ||w||2 \u003c= r\n- Training with Kalman filter\n- A DNN can be trained with unlabeled data, it is call unsupervised pertaining.\n- To integrate easily keras, use stochastic gradient descent (SGD) together with eager execution.\n- Nonsaturating activation functions.\n- Gradient Clipping.\n\n\nOthers:\n- Implement reusage of networks for drivers etc. Normally the lower layers are the important.\n- OPC UA client to get inputs from industry\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%2Fenn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fborjaest%2Fenn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborjaest%2Fenn/lists"}