ruby-fann 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NjMyNmI4NDY5MjgwMDgzYjkxMDFjOTNkMGE5ZmI4ZWI2Mjc0MjQ0Zg==
5
+ data.tar.gz: !binary |-
6
+ MGU3NjUxNmEyZTFhOTRkMzI2OWU0Zjk5YzQzYjA1MTMxMjlkZGEwYQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MGU5YmI0MWI3NDI2NDE4NGU1Y2FhYjcwMTgzOGJkZDM3MDUyNmE3NTA0OGEz
10
+ MmU4NzU3Y2UyMDIwNmNhMjE5MDNiYTMwNjRmY2I4NGQwNzhlZWUzMjM5YWMx
11
+ YWYzOWZlY2Q3NmNiN2I5OGVkNTgzOWRiODY1ZWUzMmU1MTk0YWM=
12
+ data.tar.gz: !binary |-
13
+ ZjQyOTI0NjU0NDQ5YWE0MmQ3ZDE0ZTMwMDgyMmM0YTkyZWQ5MTFkODVmM2Ji
14
+ YmE3YTU1YWEyZmI1ZjkyNDNmZDE0N2MyNzVjOTc2NGFjZmViM2EyZTI2N2Iy
15
+ ZDZlYjg0ZjI4NGRiNDUzMTJhZjFkNTllOGM5OWE2ZGQ5ZTUyMzQ=
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Ruby::Fann
1
+ # RubyFann
2
2
 
3
- Bindings to use FANN from within ruby/rails environment. Fann is a is a free open source neural network library, which implements multilayer artificial neural networks with support for both fully connected and sparsely connected networks. It is easy to use, versatile, well documented, and fast. RubyFann makes working with neural networks a breeze using ruby, with the added benefit that most of the heavy lifting is done natively.
3
+ RubyFann, or "ruby-fann" is a ruby gem that binds to FANN (Fast Artificial Neural Network) from within a ruby/rails environment. FANN is a is a free open source neural network library, which implements multilayer artificial neural networks with support for both fully connected and sparsely connected networks. It is easy to use, versatile, well documented, and fast. RubyFann makes working with neural networks a breeze using ruby, with the added benefit that most of the heavy lifting is done natively.
4
4
 
5
5
  ## Installation
6
6
 
@@ -21,6 +21,9 @@ Or install it yourself as:
21
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
22
  http://leenissen.dk/fann/
23
23
 
24
+ ruby-fann RDocs:
25
+ http://ruby-fann.rubyforge.org/
26
+
24
27
  ### Example training & subsequent execution:
25
28
 
26
29
  ```ruby
@@ -67,13 +70,15 @@ class MyFann < RubyFann::Standard
67
70
  end
68
71
  end
69
72
  ```
70
- ### A sample project using Ruby Fann to play tic-tac-toe
73
+ ### A sample project using RubyFann to play tic-tac-toe
71
74
  https://github.com/bigohstudios/tictactoe
72
75
 
73
- ## Documentation
74
- http://ruby-fann.rubyforge.org/
75
-
76
-
76
+ ## Contributors
77
+ 1. Steven Miers
78
+ 2. Ole Krüger
79
+ 3. dignati
80
+ 4. Michal Pokorný
81
+ 5. Scott Li (locksley)
77
82
 
78
83
  ## Contributing
79
84
 
@@ -1111,7 +1111,38 @@ static VALUE init_weights(VALUE self, VALUE train_data)
1111
1111
  return self;
1112
1112
  }
1113
1113
 
1114
+ /** call-seq: train(input, expected_output)
1114
1115
 
1116
+ Train with a single input-output pair.
1117
+ input - The inputs given to the network
1118
+ expected_output - The outputs expected. */
1119
+ static VALUE train(VALUE self, VALUE input, VALUE expected_output)
1120
+ {
1121
+ Check_Type(input, T_ARRAY);
1122
+ Check_Type(expected_output, T_ARRAY);
1123
+
1124
+ struct fann* f;
1125
+ Data_Get_Struct(self, struct fann, f);
1126
+
1127
+ unsigned int num_input = RARRAY_LEN(input);
1128
+ unsigned int num_output = RARRAY_LEN(expected_output);
1129
+
1130
+ fann_type data_input[num_input], data_output[num_output];
1131
+
1132
+ int i;
1133
+
1134
+ for (i = 0; i < num_input; i++) {
1135
+ data_input[i] = NUM2DBL(RARRAY_PTR(input)[i]);
1136
+ }
1137
+
1138
+ for (i = 0; i < num_output; i++) {
1139
+ data_output[i] = NUM2DBL(RARRAY_PTR(expected_output)[i]);
1140
+ }
1141
+
1142
+ fann_train(f, data_input, data_output);
1143
+
1144
+ return rb_int_new(0);
1145
+ }
1115
1146
 
1116
1147
  /** call-seq: train_on_data(train_data, max_epochs, epochs_between_reports, desired_error)
1117
1148
 
@@ -1559,6 +1590,7 @@ void Init_ruby_fann ()
1559
1590
  rb_define_method(m_rb_fann_standard_class, "print_parameters", print_parameters, 0);
1560
1591
  rb_define_method(m_rb_fann_standard_class, "randomize_weights", randomize_weights, 2);
1561
1592
  rb_define_method(m_rb_fann_standard_class, "run", run, 1);
1593
+ rb_define_method(m_rb_fann_standard_class, "train", train, 2);
1562
1594
  rb_define_method(m_rb_fann_standard_class, "train_on_data", train_on_data, 4);
1563
1595
  rb_define_method(m_rb_fann_standard_class, "train_epoch", train_epoch, 1);
1564
1596
  rb_define_method(m_rb_fann_standard_class, "test_data", test_data, 1);
@@ -1658,6 +1690,7 @@ void Init_ruby_fann ()
1658
1690
  rb_define_method(m_rb_fann_shortcut_class, "print_parameters", print_parameters, 0);
1659
1691
  rb_define_method(m_rb_fann_shortcut_class, "randomize_weights", randomize_weights, 2);
1660
1692
  rb_define_method(m_rb_fann_shortcut_class, "run", run, 1);
1693
+ rb_define_method(m_rb_fann_shortcut_class, "train", train, 2);
1661
1694
  rb_define_method(m_rb_fann_shortcut_class, "train_on_data", train_on_data, 4);
1662
1695
  rb_define_method(m_rb_fann_shortcut_class, "train_epoch", train_epoch, 1);
1663
1696
  rb_define_method(m_rb_fann_shortcut_class, "test_data", test_data, 1);
@@ -30,11 +30,11 @@ module RubyFann
30
30
  # Generate output graph with given neural network to the given output path (PNG)
31
31
  # If args[:three_dimensional] is set, then a 3d VRML graph will be generated (experimental)
32
32
  def graph(neural_net, output_path, args={})
33
- if(args[:three_dimensional])
34
- graph_viz = GraphViz::new( "G", :output => "vrml", :dim=>'3') # , :size=>"17,11"
33
+ if (args[:three_dimensional])
34
+ graph_viz = GraphViz::new( "G", :dim=>'3') # , :size=>"17,11"
35
35
  shape="point"
36
36
  else
37
- graph_viz = GraphViz::new( "G", :output => "png", :dim=>'2') # , :size=>"17,11"
37
+ graph_viz = GraphViz::new( "G", :dim=>'2') # , :size=>"17,11"
38
38
  shape="egg"
39
39
  end
40
40
 
@@ -98,8 +98,13 @@ module RubyFann
98
98
  end
99
99
 
100
100
  end
101
-
102
- graph_viz.output(:file=>output_path)
101
+
102
+ if (args[:three_dimensional])
103
+ graph_viz.output(:vrml=>output_path)
104
+ else
105
+ graph_viz.output(:png=>output_path)
106
+ end
107
+
103
108
 
104
109
  end
105
110
  end
@@ -2,7 +2,7 @@ module RubyFann
2
2
  module VERSION
3
3
  MAJOR = 1
4
4
  MINOR = 2
5
- TINY = 4
5
+ TINY = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-fann
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
5
- prerelease:
4
+ version: 1.2.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - tangledpath
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-06 00:00:00.000000000 Z
11
+ date: 2013-08-01 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Bindings to use FANN from within ruby/rails environment
15
14
  email:
@@ -49,28 +48,27 @@ files:
49
48
  - README.md
50
49
  homepage: http://github.com/tangledpath/ruby-fann
51
50
  licenses: []
51
+ metadata: {}
52
52
  post_install_message:
53
53
  rdoc_options: []
54
54
  require_paths:
55
55
  - lib
56
56
  - ext
57
57
  required_ruby_version: !ruby/object:Gem::Requirement
58
- none: false
59
58
  requirements:
60
59
  - - ! '>='
61
60
  - !ruby/object:Gem::Version
62
61
  version: '0'
63
62
  required_rubygems_version: !ruby/object:Gem::Requirement
64
- none: false
65
63
  requirements:
66
64
  - - ! '>='
67
65
  - !ruby/object:Gem::Version
68
66
  version: '0'
69
67
  requirements: []
70
68
  rubyforge_project: ruby-fann
71
- rubygems_version: 1.8.25
69
+ rubygems_version: 2.0.6
72
70
  signing_key:
73
- specification_version: 3
71
+ specification_version: 4
74
72
  summary: Bindings to use FANN from within ruby/rails environment. Fann is a is a
75
73
  free open source neural network library, which implements multilayer artificial
76
74
  neural networks with support for both fully connected and sparsely connected networks. It