ruby-fann 1.4.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63b41957229e899b6498641c04163610daeecd8d7bc989262915ed5284128172
4
- data.tar.gz: 4be842a49ec6b57d1e1b7489302b874427faec3e06d439ccc9976be49419287e
3
+ metadata.gz: 1513ab175dd525a96a3846565c6b54a2d5bf44af679144a4f7e877dd8e948e03
4
+ data.tar.gz: 9942ab1a6cd7112ec21fa4d7912f8f72e62a18ab429948cc507c73a8af5efb73
5
5
  SHA512:
6
- metadata.gz: 753f3252b1e3c9500d455b1d25f72d7ca99935739f18c5c6226cc034c55cb7e0354820b995511690eaca39da9e685e4e6883cb7a5c527ffadee92d729267e171
7
- data.tar.gz: a904cd8752595018693c65b996aaf9d6b58917cac4cde6943ca5b847e744269b4224cdd79cb1abc63be169d999ea5f8c9f9ef4e215c5f0a2626427a8c577eb86
6
+ metadata.gz: 5b0a6b6909f6d19b005454dfddf77570493ddf3618c7b51e6fd36c99b09bfa3858b489cfca80829253f1c1ed79c953cbae21b6f4a24eddd34cd37d31920d529d
7
+ data.tar.gz: 8776e0c70509d821e032b2e9b1bf7c0a323609e3bf69a7cd294ebbb192c57236c06e5cffcb869f79291d3fabe5ef17f6553cd078419f88283cdff05f33ff17d4
data/README.md CHANGED
@@ -9,7 +9,7 @@ Neural Networks in `ruby`
9
9
 
10
10
  [![Gem Version](https://badge.fury.io/rb/ruby-fann.png)](http://badge.fury.io/rb/ruby-fann)
11
11
 
12
- 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 (native) open source neural network library, which implements multilayer artificial neural networks, supporting 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.
12
+ RubyFann, or "ruby-fann" is a Ruby Gem (no Rails required) that binds to FANN (Fast Artificial Neural Network) from within a ruby/rails environment. FANN is a is a free native open source neural network library, which implements multilayer artificial neural networks, supporting 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.
13
13
 
14
14
  A talk given by our friend Ethan from Big-Oh Studios at Lone Star Ruby 2013: http://confreaks.com/videos/2609-lonestarruby2013-neural-networks-with-rubyfann
15
15
 
@@ -10,21 +10,23 @@ FANN_EXTERNAL struct fann_train_data * FANN_API fann_create_train_from_rb_ary2(
10
10
  }
11
11
 
12
12
  /*
13
- * Copied from fann_create_train_from_callback/file & modified to ease
13
+ * Copied from fann_create_train_from_callback/file & modified to ease
14
14
  * allocating from ruby arrays:
15
15
  */
16
16
  FANN_EXTERNAL struct fann_train_data * FANN_API fann_create_train_from_rb_ary(
17
- VALUE inputs,
18
- VALUE outputs
17
+ VALUE inputs,
18
+ VALUE outputs
19
19
  )
20
20
  {
21
21
  unsigned int i, j;
22
22
  fann_type *data_input, *data_output;
23
23
  struct fann_train_data *data = (struct fann_train_data *)malloc(sizeof(struct fann_train_data));
24
- unsigned int num_input = NUM2UINT(RARRAY_LEN(RARRAY_PTR(inputs)[0]));
25
- unsigned int num_output = NUM2UINT(RARRAY_LEN(RARRAY_PTR(outputs)[0]));
26
- unsigned int num_data = NUM2UINT(RARRAY_LEN(inputs));
27
-
24
+
25
+ long num_input = RARRAY_LEN(RARRAY_PTR(inputs)[0]);
26
+ long num_output = RARRAY_LEN(RARRAY_PTR(outputs)[0]);
27
+ long num_data = RARRAY_LEN(inputs);
28
+
29
+
28
30
  if(data == NULL) {
29
31
  fann_error(NULL, FANN_E_CANT_ALLOCATE_MEM);
30
32
  return NULL;
@@ -35,7 +37,6 @@ FANN_EXTERNAL struct fann_train_data * FANN_API fann_create_train_from_rb_ary(
35
37
  data->num_data = num_data;
36
38
  data->num_input = num_input;
37
39
  data->num_output = num_output;
38
-
39
40
  data->input = (fann_type **) calloc(num_data, sizeof(fann_type *));
40
41
  if(data->input == NULL)
41
42
  {
@@ -51,7 +52,6 @@ FANN_EXTERNAL struct fann_train_data * FANN_API fann_create_train_from_rb_ary(
51
52
  fann_destroy_train(data);
52
53
  return NULL;
53
54
  }
54
-
55
55
  data_input = (fann_type *) calloc(num_input * num_data, sizeof(fann_type));
56
56
  if(data_input == NULL)
57
57
  {
@@ -74,26 +74,26 @@ FANN_EXTERNAL struct fann_train_data * FANN_API fann_create_train_from_rb_ary(
74
74
  data->input[i] = data_input;
75
75
  data_input += num_input;
76
76
 
77
- inputs_i = NUM2UINT(RARRAY_PTR(inputs)[i]);
78
- outputs_i = NUM2UINT(RARRAY_PTR(inputs)[i]);
79
-
80
- if(RARRAY_LEN(inputs_i) != num_input)
77
+ inputs_i = RARRAY_PTR(inputs)[i];
78
+ outputs_i = RARRAY_PTR(outputs)[i];
79
+
80
+ if(RARRAY_LEN(inputs_i) != num_input)
81
81
  {
82
82
  rb_raise (
83
- rb_eRuntimeError,
84
- "Number of inputs at [%d] is inconsistent: (%d != %d)",
85
- i,NUM2UINT(RARRAY_LEN(inputs_i)), num_input);
83
+ rb_eRuntimeError,
84
+ "Number of inputs at [%d] is inconsistent: (%du != %d)",
85
+ i,RARRAY_LEN(inputs_i)), num_input;
86
86
  }
87
-
88
- if(RARRAY_LEN(outputs_i) != num_output)
87
+
88
+ if(RARRAY_LEN(outputs_i) != num_output)
89
89
  {
90
90
  rb_raise (
91
- rb_eRuntimeError,
92
- "Number of outputs at [%d] is inconsistent: (%d != %d)",
93
- i, NUM2UINT(RARRAY_LEN(outputs_i)), num_output);
91
+ rb_eRuntimeError,
92
+ "Number of outputs at [%d] is inconsistent: (%d != %d)",
93
+ i, RARRAY_LEN(outputs_i)), num_output;
94
94
  }
95
-
96
-
95
+
96
+
97
97
  for(j = 0; j != num_input; j++)
98
98
  {
99
99
  data->input[i][j]=NUM2DBL(RARRAY_PTR(inputs_i)[j]);
@@ -101,12 +101,12 @@ FANN_EXTERNAL struct fann_train_data * FANN_API fann_create_train_from_rb_ary(
101
101
 
102
102
  data->output[i] = data_output;
103
103
  data_output += num_output;
104
-
104
+
105
105
  for(j = 0; j != num_output; j++)
106
106
  {
107
107
  data->output[i][j]=NUM2DBL(RARRAY_PTR(outputs_i)[j]);
108
108
  }
109
109
  }
110
-
110
+
111
111
  return data;
112
112
  }