@@ -21,13 +21,19 @@ Spectator.describe Ai4cr::NeuralNetwork::Cmn::MiniNetManager do
21
21
22
22
let(config_adam) {
23
23
config_default_randomized.merge(
24
- name: " Adam" , learning_rate: ancestor_adam_learning_rate_expected
24
+ name: " Adam" ,
25
+ learning_rate: ancestor_adam_learning_rate_expected,
26
+ momentum: Ai4cr ::Data ::Utils .rand_excluding,
27
+ deriv_scale: Ai4cr ::Data ::Utils .rand_excluding / 2.0
25
28
)
26
29
}
27
30
28
31
let(config_eve) {
29
32
config_default_randomized.merge(
30
- name: " Eve" , learning_rate: ancestor_eve_learning_rate_expected
33
+ name: " Eve" ,
34
+ learning_rate: ancestor_eve_learning_rate_expected,
35
+ momentum: Ai4cr ::Data ::Utils .rand_excluding,
36
+ deriv_scale: Ai4cr ::Data ::Utils .rand_excluding / 2.0
31
37
)
32
38
}
33
39
@@ -44,93 +50,93 @@ Spectator.describe Ai4cr::NeuralNetwork::Cmn::MiniNetManager do
44
50
expect(ancestor_adam.learning_rate).not_to eq(ancestor_eve.learning_rate)
45
51
end
46
52
47
- # context "birth_id's are in the consistent order (when birthed in order" do
48
- # it "first Adam" do
49
- # expected_birth_counter = 0
50
-
51
- # # Adam
52
- # expected_birth_counter += 1
53
- # expect(ancestor_adam.birth_id).to eq(expected_birth_counter)
54
-
55
- # puts_debug
56
- # puts_debug "ancestor_adam: #{ancestor_adam.to_json}"
57
- # end
58
-
59
- # it "first Adam then Eve" do
60
- # expected_birth_counter = 0
61
-
62
- # # Adam
63
- # expected_birth_counter += 1
64
- # expect(ancestor_adam.birth_id).to eq(expected_birth_counter)
65
-
66
- # # Eve
67
- # expected_birth_counter += 1
68
- # expect(ancestor_eve.birth_id).to eq(expected_birth_counter)
69
-
70
- # puts_debug
71
- # puts_debug "ancestor_adam: #{ancestor_adam.to_json}"
72
- # puts_debug
73
- # puts_debug "ancestor_eve: #{ancestor_eve.to_json}"
74
- # end
75
-
76
- # it "first Adam then Eve followed by Cain" do
77
- # expected_birth_counter = 0
78
-
79
- # # Adam
80
- # expected_birth_counter += 1
81
- # expect(ancestor_adam.birth_id).to eq(expected_birth_counter)
82
-
83
- # # Eve
84
- # expected_birth_counter += 1
85
- # expect(ancestor_eve.birth_id).to eq(expected_birth_counter)
86
-
87
- # # Cain
88
- # expected_birth_counter += 1
89
- # child_1 = my_breed_manager.breed(ancestor_adam, ancestor_eve, delta: delta_child_1)
90
- # child_1.name = "Cain, child of #{child_1.name} and #{ancestor_eve.name}"
91
- # expect(child_1.birth_id).to eq(expected_birth_counter)
92
-
93
- # puts_debug
94
- # puts_debug "ancestor_adam: #{ancestor_adam.to_json}"
95
- # puts_debug
96
- # puts_debug "ancestor_eve: #{ancestor_eve.to_json}"
97
- # puts_debug
98
- # puts_debug "child_1: #{child_1.to_json}"
99
- # end
100
-
101
- # it "first Adam then Eve followed by Cain and then Abel" do
102
- # expected_birth_counter = 0
103
-
104
- # # Adam
105
- # expected_birth_counter += 1
106
- # expect(ancestor_adam.birth_id).to eq(expected_birth_counter)
107
-
108
- # # Eve
109
- # expected_birth_counter += 1
110
- # expect(ancestor_eve.birth_id).to eq(expected_birth_counter)
111
-
112
- # # Cain
113
- # expected_birth_counter += 1
114
- # child_1 = my_breed_manager.breed(ancestor_adam, ancestor_eve, delta: delta_child_1)
115
- # child_1.name = "Cain, child of #{child_1.name} and #{ancestor_eve.name}"
116
- # expect(child_1.birth_id).to eq(expected_birth_counter)
117
-
118
- # # Abel
119
- # expected_birth_counter += 1
120
- # child_2 = my_breed_manager.breed(ancestor_adam, ancestor_eve, delta: delta_child_2)
121
- # child_2.name = "Abel, child of #{child_2.name} and #{ancestor_eve.name}"
122
- # expect(child_2.birth_id).to eq(expected_birth_counter)
123
-
124
- # puts_debug
125
- # puts_debug "ancestor_adam: #{ancestor_adam.to_json}"
126
- # puts_debug
127
- # puts_debug "ancestor_eve: #{ancestor_eve.to_json}"
128
- # puts_debug
129
- # puts_debug "child_1: #{child_1.to_json}"
130
- # puts_debug
131
- # puts_debug "child_2: #{child_2.to_json}"
132
- # end
133
- # end
53
+ context " birth_id's are in the consistent order (when birthed in order" do
54
+ it " first Adam" do
55
+ expected_birth_counter = 0
56
+
57
+ # Adam
58
+ expected_birth_counter += 1
59
+ expect(ancestor_adam.birth_id).to eq(expected_birth_counter)
60
+
61
+ puts_debug
62
+ puts_debug " ancestor_adam: #{ ancestor_adam.to_json } "
63
+ end
64
+
65
+ it " first Adam then Eve" do
66
+ expected_birth_counter = 0
67
+
68
+ # Adam
69
+ expected_birth_counter += 1
70
+ expect(ancestor_adam.birth_id).to eq(expected_birth_counter)
71
+
72
+ # Eve
73
+ expected_birth_counter += 1
74
+ expect(ancestor_eve.birth_id).to eq(expected_birth_counter)
75
+
76
+ puts_debug
77
+ puts_debug " ancestor_adam: #{ ancestor_adam.to_json } "
78
+ puts_debug
79
+ puts_debug " ancestor_eve: #{ ancestor_eve.to_json } "
80
+ end
81
+
82
+ it " first Adam then Eve followed by Cain" do
83
+ expected_birth_counter = 0
84
+
85
+ # Adam
86
+ expected_birth_counter += 1
87
+ expect(ancestor_adam.birth_id).to eq(expected_birth_counter)
88
+
89
+ # Eve
90
+ expected_birth_counter += 1
91
+ expect(ancestor_eve.birth_id).to eq(expected_birth_counter)
92
+
93
+ # Cain
94
+ expected_birth_counter += 1
95
+ child_1 = my_breed_manager.breed(ancestor_adam, ancestor_eve, delta: delta_child_1)
96
+ child_1.name = " Cain, child of #{ child_1.name } and #{ ancestor_eve.name } "
97
+ expect(child_1.birth_id).to eq(expected_birth_counter)
98
+
99
+ puts_debug
100
+ puts_debug " ancestor_adam: #{ ancestor_adam.to_json } "
101
+ puts_debug
102
+ puts_debug " ancestor_eve: #{ ancestor_eve.to_json } "
103
+ puts_debug
104
+ puts_debug " child_1: #{ child_1.to_json } "
105
+ end
106
+
107
+ it " first Adam then Eve followed by Cain and then Abel" do
108
+ expected_birth_counter = 0
109
+
110
+ # Adam
111
+ expected_birth_counter += 1
112
+ expect(ancestor_adam.birth_id).to eq(expected_birth_counter)
113
+
114
+ # Eve
115
+ expected_birth_counter += 1
116
+ expect(ancestor_eve.birth_id).to eq(expected_birth_counter)
117
+
118
+ # Cain
119
+ expected_birth_counter += 1
120
+ child_1 = my_breed_manager.breed(ancestor_adam, ancestor_eve, delta: delta_child_1)
121
+ child_1.name = " Cain, child of #{ child_1.name } and #{ ancestor_eve.name } "
122
+ expect(child_1.birth_id).to eq(expected_birth_counter)
123
+
124
+ # Abel
125
+ expected_birth_counter += 1
126
+ child_2 = my_breed_manager.breed(ancestor_adam, ancestor_eve, delta: delta_child_2)
127
+ child_2.name = " Abel, child of #{ child_2.name } and #{ ancestor_eve.name } "
128
+ expect(child_2.birth_id).to eq(expected_birth_counter)
129
+
130
+ puts_debug
131
+ puts_debug " ancestor_adam: #{ ancestor_adam.to_json } "
132
+ puts_debug
133
+ puts_debug " ancestor_eve: #{ ancestor_eve.to_json } "
134
+ puts_debug
135
+ puts_debug " child_1: #{ child_1.to_json } "
136
+ puts_debug
137
+ puts_debug " child_2: #{ child_2.to_json } "
138
+ end
139
+ end
134
140
135
141
describe " #mix_parts" do
136
142
context " first Adam then Eve followed by Cain" do
@@ -214,91 +220,3 @@ Spectator.describe Ai4cr::NeuralNetwork::Cmn::MiniNetManager do
214
220
end
215
221
end
216
222
end
217
-
218
- # let(weights_expected_1) {
219
- # ancestor_adam.weights.map_with_index do |sa, i|
220
- # parent_a_part = sa
221
- # parent_b_part = ancestor_eve.weights[i]
222
-
223
- # vector_a_to_b = parent_b_part - parent_a_part
224
- # parent_a_part + (delta_child_1 * vector_a_to_b)
225
- # end
226
- # }
227
- # let(weights_expected_2) {
228
- # ancestor_adam.weights.map_with_index do |sa, i|
229
- # parent_a_part = sa
230
- # parent_b_part = ancestor_eve.weights[i]
231
-
232
- # vector_a_to_b = parent_b_part - parent_a_part
233
- # parent_a_part + (delta_child_2 * vector_a_to_b)
234
- # end
235
- # }
236
-
237
- # let(momentum_expected_1) {
238
- # ancestor_adam.momentum.map_with_index do |sa, i|
239
- # parent_a_part = sa
240
- # parent_b_part = ancestor_eve.momentum[i]
241
-
242
- # vector_a_to_b = parent_b_part - parent_a_part
243
- # parent_a_part + (delta_child_1 * vector_a_to_b)
244
- # end
245
- # }
246
- # let(momentum_expected_2) {
247
- # ancestor_adam.momentum.map_with_index do |sa, i|
248
- # parent_a_part = sa
249
- # parent_b_part = ancestor_eve.momentum[i]
250
-
251
- # vector_a_to_b = parent_b_part - parent_a_part
252
- # parent_a_part + (delta_child_2 * vector_a_to_b)
253
- # end
254
- # }
255
-
256
- # let(config_cain) {
257
- # config_default_randomized.merge(
258
- # name: "Cain", learning_rate: ancestor_adam_learning_rate_expected
259
- # )
260
- # }
261
-
262
- # let(config_abel) {
263
- # config_default_randomized.merge(
264
- # name: "Abel", learning_rate: ancestor_adam_learning_rate_expected
265
- # )
266
- # }
267
-
268
- # expect(ancestor_adam.learning_rate).to eq(ancestor_adam_learning_rate_expected)
269
-
270
- # expected_birth_counter += 1
271
- # expect(ancestor_eve.birth_id).to eq(expected_birth_counter)
272
- # expect(ancestor_eve.learning_rate).to eq(ancestor_eve_learning_rate_expected)
273
-
274
- # # cain
275
- # child_1 = my_breed_manager.breed(ancestor_adam, ancestor_eve, delta: delta_child_1)
276
- # child_1.name = "Cain, child of #{child_1.name} and #{ancestor_eve.name}"
277
-
278
- # puts_debug "child_1: #{child_1.to_json}"
279
- # expected_birth_counter += 1
280
- # expect(child_1.birth_id).to eq(expected_birth_counter)
281
- # expect(child_1.learning_rate).to eq(delta_child_1)
282
-
283
- # # expect(child_1.weights).to eq(weights_expected_1)
284
- # # expect(child_1.momentum).to eq(momentum_expected_1)
285
-
286
- # # abel
287
- # child_2 = my_breed_manager.breed(ancestor_adam, ancestor_eve, delta: delta_child_2)
288
- # child_2.name = "Abel, child of #{child_2.name} and #{ancestor_eve.name}"
289
-
290
- # puts_debug "child_2: #{child_2.to_json}"
291
- # expected_birth_counter += 1
292
- # expect(child_2.birth_id).to eq(expected_birth_counter)
293
- # expect(child_2.learning_rate).to eq(delta_child_2)
294
-
295
- # # expect(child_2.weights).to eq(weights_expected_2)
296
- # # expect(child_2.momentum).to eq(momentum_expected_2)
297
-
298
- # puts_debug
299
- # puts_debug "Now, in order or youngest to oldest:"
300
- # [ancestor_adam, ancestor_eve, child_1, child_2].sort_by do |person|
301
- # (- person.birth_id)
302
- # end.each do |person|
303
- # puts_debug "person: #{person.to_json}"
304
- # end
0 commit comments