{"id":13413354,"url":"https://github.com/goml/gobrain","last_synced_at":"2025-03-14T19:31:57.321Z","repository":{"id":16524336,"uuid":"19277524","full_name":"goml/gobrain","owner":"goml","description":"Neural Networks written in go","archived":false,"fork":false,"pushed_at":"2020-12-12T12:34:25.000Z","size":45,"stargazers_count":554,"open_issues_count":2,"forks_count":59,"subscribers_count":24,"default_branch":"master","last_synced_at":"2024-05-22T08:27:30.341Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/goml.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":"2014-04-29T13:32:36.000Z","updated_at":"2024-04-13T17:46:34.000Z","dependencies_parsed_at":"2022-08-07T08:15:26.295Z","dependency_job_id":null,"html_url":"https://github.com/goml/gobrain","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/goml%2Fgobrain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goml%2Fgobrain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goml%2Fgobrain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goml%2Fgobrain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goml","download_url":"https://codeload.github.com/goml/gobrain/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243635360,"owners_count":20322926,"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-07-30T20:01:38.460Z","updated_at":"2025-03-14T19:31:57.054Z","avatar_url":"https://github.com/goml.png","language":"Go","readme":"# gobrain\n\nNeural Networks written in go\n\n[![GoDoc](https://godoc.org/github.com/goml/gobrain?status.svg)](https://godoc.org/github.com/goml/gobrain)\n[![Build Status](https://travis-ci.org/goml/gobrain.svg?branch=master)](https://travis-ci.org/goml/gobrain)\n\n## Getting Started\nThe version `1.0.0` includes just basic Neural Network functions such as Feed Forward and Elman Recurrent Neural Network.\nA simple Feed Forward Neural Network can be constructed and trained as follows:\n\n```go\npackage main\n\nimport (\n\t\"github.com/goml/gobrain\"\n\t\"math/rand\"\n)\n\nfunc main() {\n\t// set the random seed to 0\n\trand.Seed(0)\n\n\t// create the XOR representation patter to train the network\n\tpatterns := [][][]float64{\n\t\t{{0, 0}, {0}},\n\t\t{{0, 1}, {1}},\n\t\t{{1, 0}, {1}},\n\t\t{{1, 1}, {0}},\n\t}\n\n\t// instantiate the Feed Forward\n\tff := \u0026gobrain.FeedForward{}\n\n\t// initialize the Neural Network;\n\t// the networks structure will contain:\n\t// 2 inputs, 2 hidden nodes and 1 output.\n\tff.Init(2, 2, 1)\n\n\t// train the network using the XOR patterns\n\t// the training will run for 1000 epochs\n\t// the learning rate is set to 0.6 and the momentum factor to 0.4\n\t// use true in the last parameter to receive reports about the learning error\n\tff.Train(patterns, 1000, 0.6, 0.4, true)\n}\n\n```\n\nAfter running this code the network will be trained and ready to be used.\n\nThe network can be tested running using the `Test` method, for instance:\n\n```go\nff.Test(patterns)\n```\n\nThe test operation will print in the console something like:\n\n```\n[0 0] -\u003e [0.057503945708445]  :  [0]\n[0 1] -\u003e [0.930100635071210]  :  [1]\n[1 0] -\u003e [0.927809966227284]  :  [1]\n[1 1] -\u003e [0.097408795324620]  :  [0]\n```\n\nWhere the first values are the inputs, the values after the arrow `-\u003e` are the output values from the network and the values after `:` are the expected outputs.\n\nThe method `Update` can be used to predict the output given an input, for example:\n\n```go\ninputs := []float64{1, 1}\nff.Update(inputs)\n```\n\nthe output will be a vector with values ranging from `0` to `1`.\n\nIn the example folder there are runnable examples with persistence of the trained network on file.\n\nIn example/02 the network is saved on file and in example/03 the network is loaded from file.\n\nTo run the example cd in the folder and run\n\n\tgo run main.go\n\n## Recurrent Neural Network\n\nThis library implements Elman's Simple Recurrent Network.\n\nTo take advantage of this, one can use the `SetContexts` function.\n\n```go\nff.SetContexts(1, nil)\n```\n\nIn the example above, a single context will be created initialized with `0.5`. It is also possible\nto create custom initialized contexts, for instance:\n\n```go\ncontexts := [][]float64{\n\t{0.5, 0.8, 0.1}\n}\n```\n\nNote that custom contexts must have the same size of hidden nodes + 1 (bias node),\nin the example above the size of hidden nodes is 2, thus the context has 3 values.\n\n## Changelog\n* 1.0.0 - Added Feed Forward Neural Network with contexts from Elman RNN\n\n","funding_links":[],"categories":["Machine Learning","Go","Golang","\u003cspan id=\"机器学习-machine-learning\"\u003e机器学习 Machine Learning\u003c/span\u003e","Neural Networks","机器学习","Relational Databases"],"sub_categories":["Advanced Console UIs","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","Tools","[Tools](#tools-1)","Speech Recognition","Search and Analytic Databases","Vector Database","SQL 查询语句构建库","检索及分析资料库","交流"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoml%2Fgobrain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoml%2Fgobrain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoml%2Fgobrain/lists"}