Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drhuffman12/cmn basic rnn part 6 (#54)
* drhuffman12/cmn_basic_rnn_part_6 comment out RnnConcerns::TrainInSequence while I refactor RnnConcerns::SplitTrainingDat * drhuffman12/cmn_basic_rnn_part_6 refactor RnnConcerns::SplitTrainingDat * drhuffman12/cmn_basic_rnn_part_6 replace '#split_for_training' with '#indexes_for_training_and_eval' and 'TrainingData' with 'TrainingIndexes' * unset ameba version * set ameba to master branch * disable ameba (for now) * disable ameba (for now) * disable ameba * drhuffman12/cmn_basic_rnn_part_6 reorg RNN related under `Ai4cr::NeuralNetwork::Rnn` * drhuffman12/cmn_basic_rnn_part_6 reorg RNN related under `Ai4cr::NeuralNetwork::Rnn` * drhuffman12/cmn_basic_rnn_part_6 code cleanup * drhuffman12/cmn_basic_rnn_part_6 try to force full docker rebuild * drhuffman12/cmn_basic_rnn_part_6 try to force full docker rebuild * drhuffman12/cmn_basic_rnn_part_6 adjust version/branch of ascii_bar_charter * drhuffman12/cmn_basic_rnn_part_6 reorg CI steps (so can see Crystal version) * drhuffman12/cmn_basic_rnn_part_6 shuffle dependencies * drhuffman12/cmn_basic_rnn_part_6 shuffle dependencies * drhuffman12/cmn_basic_rnn_part_6 Cleanup requires * drhuffman12/cmn_basic_rnn_part_6 refactoring re error_distance and related * drhuffman12/cmn_basic_rnn_part_6 refactoring re error_distance and related (part 2) * drhuffman12/cmn_basic_rnn_part_6 refactoring re error_distance and related (part 3) * drhuffman12/cmn_basic_rnn_part_6 refactoring re error_distance and related (part 4) * drhuffman12/cmn_basic_rnn_part_6 refactoring re error_distance and related (part 5) * drhuffman12/cmn_basic_rnn_part_6 error_distance should decrease each training round * drhuffman12/cmn_basic_rnn_part_6 add CalcAndGuess for RnnSimpleTeam * drhuffman12/cmn_basic_rnn_part_6 inital code and tests for RnnSimpleTeamConcerns::TrainAndAdjust * drhuffman12/cmn_basic_rnn_part_6 comment out 'debug_msg' * drhuffman12/cmn_basic_rnn_part_6 add BreedUtils and Breeder * drhuffman12/cmn_basic_rnn_part_6 formatting * drhuffman12/cmn_basic_rnn_part_6 comment out test for Ai4cr::NeuralNetwork::Rnn::RnnSimpleConcerns::TrainAndAdjust till that is refactored w/ Breeder * drhuffman12/cmn_basic_rnn_part_6 refactor; remove RnnSimpleTeam (take a diff approach in later PR) * drhuffman12/cmn_basic_rnn_part_6 bump version
- Loading branch information
1 parent
f4ef197
commit a08a797
Showing
46 changed files
with
1,213 additions
and
1,068 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# FROM crystallang/crystal:nightly-build | ||
FROM crystallang/crystal:nightly-alpine-build | ||
|
||
WORKDIR /app | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
require "./../spec_helper" | ||
require "./../spectator_helper" | ||
require "./../../src/ai4cr/breed_utils.cr" | ||
|
||
# class Breeder | ||
# include Ai4cr::BreedUtils | ||
# end | ||
|
||
Spectator.describe Ai4cr::BreedUtils do | ||
let(parents1) { (-10..0).to_a.map { |i| i/10.0 } } | ||
let(parents2) { (0..10).to_a.map { |i| i/10.0 } } | ||
|
||
let(breeder) { | ||
Ai4cr::Breeder.new | ||
} | ||
|
||
# before(:each) do | ||
# include Ai4cr::BreedUtils | ||
# end | ||
|
||
describe "breed_value" do | ||
let(parent_a) { 0.0 } | ||
let(parent_b) { 1.0 } | ||
let(p_dist) { 1.0 * (parent_b - parent_a) } | ||
let(c_min) { parent_a - 0.5 } | ||
let(c_max) { parent_a + 2 * p_dist - 0.5 } | ||
|
||
context "debug" do | ||
it "p_dist" do | ||
expect(p_dist).to eq(1.0) | ||
end | ||
|
||
it "c_min" do | ||
expect(c_min).to eq(-0.5) | ||
end | ||
|
||
it "c_max" do | ||
expect(c_max).to eq(1.5) | ||
end | ||
end | ||
|
||
context "returns" do | ||
it "a Float64" do | ||
child = breeder.breed_value(0, 1) | ||
|
||
expect(child).to be_a(Float64) | ||
end | ||
|
||
context "between" do | ||
it "expected 'min'" do | ||
child = breeder.breed_value(0, 1) | ||
|
||
expect(child).to be >= c_min | ||
end | ||
|
||
it "expected 'max'" do | ||
child = breeder.breed_value(0, 1) | ||
|
||
expect(c_max).to be >= child | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe "breed_nested" do | ||
context "given two Int32 values" do | ||
let(parent_a) { 0 } | ||
let(parent_b) { 1 } | ||
|
||
it "does not raise" do | ||
expect { | ||
breeder.breed_nested(parent_a, parent_b) | ||
}.not_to raise_error | ||
end | ||
|
||
context "returns" do | ||
it "a Float64" do | ||
child = breeder.breed_nested(parent_a, parent_b) | ||
|
||
expect(child).to be_a(Float64) | ||
end | ||
end | ||
end | ||
|
||
context "given two Float64 values" do | ||
let(parent_a) { 0.0 } | ||
let(parent_b) { 1.0 } | ||
|
||
it "does not raise" do | ||
expect { | ||
breeder.breed_nested(parent_a, parent_b) | ||
}.not_to raise_error | ||
end | ||
|
||
context "returns" do | ||
it "a Float64" do | ||
child = breeder.breed_nested(parent_a, parent_b) | ||
|
||
expect(child).to be_a(Float64) | ||
end | ||
end | ||
end | ||
|
||
context "given two Array(Float64) values" do | ||
let(parent_a) { [0.0, 0.1] } | ||
let(parent_b) { [0.9, 1.0] } | ||
|
||
it "does not raise" do | ||
expect { | ||
breeder.breed_nested(parent_a, parent_b) | ||
}.not_to raise_error | ||
end | ||
|
||
context "returns" do | ||
it "a Float64" do | ||
child = breeder.breed_nested(parent_a, parent_b) | ||
|
||
expect(child).to be_a(Array(Float64)) | ||
end | ||
end | ||
end | ||
|
||
# context "given two Hash(String, Float64) values" do | ||
# let(parent_a) { | ||
# Hash{"zero" => 0.0} | ||
# } | ||
# let(parent_b) { | ||
# Hash{"one" => 1.0} | ||
# } | ||
|
||
# it "does not raise" do | ||
# expect { | ||
# breeder.breed_nested(parent_a, parent_b) | ||
# }.not_to raise_error | ||
# end | ||
|
||
# context "returns" do | ||
# it "a Float64" do | ||
# child = breeder.breed_nested(parent_a, parent_b) | ||
|
||
# expect(child).to be_a(parent_a.class) | ||
# end | ||
# end | ||
# end | ||
end | ||
end |
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
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
Oops, something went wrong.