ruby-fann 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +25 -5
- data/lib/ruby_fann/neurotica.rb +6 -3
- data/lib/ruby_fann/version.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -18,25 +18,38 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
+
First, Go here & read about FANN. You don't need to install it before using the gem, but understanding FANN will help you understand what you can do with the ruby-fann gem:
|
22
|
+
http://leenissen.dk/fann/
|
23
|
+
|
21
24
|
### Example training & subsequent execution:
|
22
25
|
|
23
26
|
```ruby
|
24
27
|
require 'ruby-fann'
|
25
28
|
train = RubyFann::TrainData.new(:inputs=>[[0.3, 0.4, 0.5], [0.1, 0.2, 0.3]], :desired_outputs=>[[0.7], [0.8]])
|
26
|
-
fann = RubyFann::Standard.new(:num_inputs=>
|
27
|
-
fann.train_on_data(train, 1000, 10, 0.1)
|
29
|
+
fann = RubyFann::Standard.new(:num_inputs=>3, :hidden_neurons=>[2, 8, 4, 3, 4], :num_outputs=>1)
|
30
|
+
fann.train_on_data(train, 1000, 10, 0.1) # 1000 max_epochs, 10 errors between reports and 0.1 desired MSE (mean-squared-error)
|
28
31
|
outputs = fann.run([0.3, 0.2, 0.4])
|
29
32
|
```
|
30
33
|
|
31
|
-
### Save
|
34
|
+
### Save training data to file and use it later (continued from above)
|
32
35
|
|
33
36
|
```ruby
|
34
37
|
train.save('verify.train')
|
35
38
|
train = RubyFann::TrainData.new(:filename=>'verify.train')
|
36
|
-
|
39
|
+
# Train again with 10000 max_epochs, 20 errors between reports and 0.01 desired MSE (mean-squared-error)
|
40
|
+
# This will take longer:
|
41
|
+
fann.train_on_data(train, 10000, 20, 0.01)
|
42
|
+
```
|
43
|
+
|
44
|
+
### Save trained network to file and use it later (continued from above)
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
fann.save('foo.net')
|
48
|
+
saved_nn = RubyFann::Standard.new(:filename=>"foo.net")
|
49
|
+
saved_nn.run([0.3, 0.2, 0.4])
|
37
50
|
```
|
38
51
|
|
39
|
-
###
|
52
|
+
### Custom training using a callback method
|
40
53
|
|
41
54
|
This callback function can be called during training when using train_on_data, train_on_file or cascadetrain_on_data.
|
42
55
|
|
@@ -54,6 +67,13 @@ class MyFann < RubyFann::Standard
|
|
54
67
|
end
|
55
68
|
end
|
56
69
|
```
|
70
|
+
### A sample project using Ruby Fann to play tic-tac-toe
|
71
|
+
https://github.com/bigohstudios/tictactoe
|
72
|
+
|
73
|
+
## Documentation
|
74
|
+
http://ruby-fann.rubyforge.org/
|
75
|
+
|
76
|
+
|
57
77
|
|
58
78
|
## Contributing
|
59
79
|
|
data/lib/ruby_fann/neurotica.rb
CHANGED
@@ -48,9 +48,12 @@ module RubyFann
|
|
48
48
|
fillcolor = "transparent" # : "khaki3"
|
49
49
|
layer = neuron[:layer]
|
50
50
|
fillcolor = case layer
|
51
|
-
when 0
|
52
|
-
|
53
|
-
|
51
|
+
when 0
|
52
|
+
@input_layer_color
|
53
|
+
when max_layer
|
54
|
+
@output_layer_color
|
55
|
+
else
|
56
|
+
@hidden_layer_colors[(layer-1) % @hidden_layer_colors.length]
|
54
57
|
end
|
55
58
|
|
56
59
|
#puts "adding neuron with #{neuron[:value]}"
|
data/lib/ruby_fann/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-fann
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-06 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Bindings to use FANN from within ruby/rails environment
|
15
15
|
email:
|
@@ -67,8 +67,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
requirements: []
|
70
|
-
rubyforge_project:
|
71
|
-
rubygems_version: 1.8.
|
70
|
+
rubyforge_project: ruby-fann
|
71
|
+
rubygems_version: 1.8.25
|
72
72
|
signing_key:
|
73
73
|
specification_version: 3
|
74
74
|
summary: Bindings to use FANN from within ruby/rails environment. Fann is a is a
|