-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
124 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,61 @@ | ||
gobrain | ||
======= | ||
#gobrain | ||
|
||
Neural Networks written in go | ||
|
||
|
||
## Getting Started | ||
The version `1.0.0` includes just basic Neural Network functions such as Feed Forward and Elman Recurrent Neural Network. | ||
A simple Feed Forward Neural Network can be constructed and trained as follows: | ||
|
||
```golang | ||
// set the random seed to 0 | ||
rand.Seed(0) | ||
|
||
// create the XOR representation patter to train the network | ||
patterns := [][][]float64{ | ||
{{0, 0}, {0}}, | ||
{{0, 1}, {1}}, | ||
{{1, 0}, {1}}, | ||
{{1, 1}, {0}}, | ||
} | ||
|
||
// instantiate the Feed Forward | ||
ff := &nn.FeedForward{} | ||
|
||
// initialize the Neural Network; | ||
// the networks structure will contain: | ||
// 2 inputs, 2 hidden nodes and 1 output. | ||
ff.Init(2, 2, 1) | ||
|
||
// train the network using the XOR patterns | ||
// the training will run for 1000 epochs | ||
// the learning rate is set to 0.6 and the momentum factor to 0.4 | ||
// use true in the last parameter to receive reports about the learning error | ||
ff.Train(patterns, 1000, 0.6, 0.4, true) | ||
``` | ||
|
||
After running this code the network will be trained and ready to be used. | ||
|
||
The network can be tested running using the `Test` method, for instance: | ||
|
||
```golang | ||
ff.Test(patterns) | ||
``` | ||
|
||
The test operation will print in the console something like: | ||
|
||
``` | ||
[0 0] -> [0.057503945708445] : [0] | ||
[0 1] -> [0.930100635071210] : [1] | ||
[1 0] -> [0.927809966227284] : [1] | ||
[1 1] -> [0.097408795324620] : [0] | ||
``` | ||
|
||
Where the first values are the inputs, the values after the arrow `->` are the output values from the network and the values after `:` are the expected outputs. | ||
|
||
## Recurrent Neural Network | ||
|
||
|
||
## Changelog | ||
* 1.0.0 - Added Feed Forward Neural Network with contexts from Elman RNN | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters