Skip to content

Commit

Permalink
test(trainable_engine): more robust num iterations
Browse files Browse the repository at this point in the history
This commit sets the number of training iterations in each unit
test so that the tests pass repeatedly even when the random_init
subroutine's "repeatable" argument is set to .false. in test/main.f90.
  • Loading branch information
rouson committed Jun 30, 2023
1 parent 48a6680 commit 7995aca
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions test/trainable_engine_test_m.f90
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,27 @@ function results() result(test_results)
associate( &
descriptions => &
[ character(len=len(longest_description)) :: &
"learning the mapping (true,true) -> true with 2 hidden layers trained on skewed AND-gate data" ,&
"learning the mapping (false,true) -> false with 2 hidden layers trained on skewed AND-gate data" ,&
"learning the mapping (true,false) -> false with 2 hidden layers trained on skewed AND-gate data" ,&
"learning the mapping (false,false) -> false with 2 hidden layers trained on skewed AND-gate data" ,&
"learning the mapping (true,true) -> false with 2 hidden layers trained on skewed NOT-AND-gate data" ,&
"learning the mapping (false,true) -> true with 2 hidden layers trained on skewed NOT-AND-gate data" ,&
"learning the mapping (true,false) -> true with 2 hidden layers trained on skewed NOT-AND-gate data" ,&
"learning the mapping (false,false) -> true with 2 hidden layers trained on skewed NOT-AND-gate data" ,&
"learning the mapping (true,true) -> true with 2 hidden layers trained on symmetric OR-gate data and random weights" ,&
"learning the mapping (false,true) -> true with 2 hidden layers trained on symmetric OR-gate data and random weights" ,&
"learning the mapping (true,false) -> true with 2 hidden layers trained on symmetric OR-gate data and random weights" ,&
"learning the mapping (false,false) -> false with 2 hidden layers trained on symmetric OR-gate data and random weights",&
"learning the mapping (true,true) -> false with 2 hidden layers trained on XOR-gate data and random weights" ,&
"learning the mapping (false,true) -> true with 2 hidden layers trained on XOR-gate data and random weights" ,&
"learning the mapping (true,false) -> true with 2 hidden layers trained on XOR-gate data and random weights" ,&
"learning the mapping (false,false) -> false with 2 hidden layers trained on XOR-gate data and random weights" &
"learning the mapping (true,true) -> true with 2 hidden layers trained on skewed AND-gate data" ,&
"learning the mapping (false,true) -> false with 2 hidden layers trained on skewed AND-gate data" ,&
"learning the mapping (true,false) -> false with 2 hidden layers trained on skewed AND-gate data" ,&
"learning the mapping (false,false) -> false with 2 hidden layers trained on skewed AND-gate data" ,&
"learning the mapping (true,true) -> false with 2 hidden layers trained on skewed NOT-AND-gate data" ,&
"learning the mapping (false,true) -> true with 2 hidden layers trained on skewed NOT-AND-gate data" ,&
"learning the mapping (true,false) -> true with 2 hidden layers trained on skewed NOT-AND-gate data" ,&
"learning the mapping (false,false) -> true with 2 hidden layers trained on skewed NOT-AND-gate data" ,&
"learning the mapping (true,true) -> true with 2 hidden layers trained on symmetric OR-gate data and random weights" ,&
"learning the mapping (false,true) -> true with 2 hidden layers trained on symmetric OR-gate data and random weights" ,&
"learning the mapping (true,false) -> true with 2 hidden layers trained on symmetric OR-gate data and random weights" ,&
"learning the mapping (false,false) -> false with 2 hidden layers trained on symmetric OR-gate data and random weights" ,&
"learning the mapping (true,true) -> false with 2 hidden layers trained on symmetric XOR-gate data and random weights" ,&
"learning the mapping (false,true) -> true with 2 hidden layers trained on symmetric XOR-gate data and random weights" ,&
"learning the mapping (true,false) -> true with 2 hidden layers trained on symmetric XOR-gate data and random weights" ,&
"learning the mapping (false,false) -> false with 2 hidden layers trained on symmetric XOR-gate data and random weights" &
], outcomes => [ &
and_gate_with_skewed_training_data(), &
not_and_gate_with_skewed_training_data(), &
or_gate_with_symmetric_training_data(), &
xor_gate() &
or_gate_with_random_weights(), &
xor_gate_with_random_weights() &
] &
)
associate(d => size(descriptions), o => size(outcomes))
Expand Down Expand Up @@ -149,7 +149,7 @@ function and_gate_with_skewed_training_data() result(test_passes)
type(outputs_t), allocatable :: actual_outputs(:)
real(rkind), parameter :: tolerance = 1.E-02_rkind
real(rkind), allocatable :: harvest(:,:,:)
integer, parameter :: num_inputs=2, mini_batch_size = 1, num_iterations=14000
integer, parameter :: num_inputs=2, mini_batch_size = 1, num_iterations=20000
integer batch, iter, i

allocate(harvest(num_inputs, mini_batch_size, num_iterations))
Expand Down Expand Up @@ -193,7 +193,7 @@ function not_and_gate_with_skewed_training_data() result(test_passes)
type(outputs_t), allocatable :: actual_outputs(:)
real(rkind), parameter :: tolerance = 1.E-02_rkind
real(rkind), allocatable :: harvest(:,:,:)
integer, parameter :: num_inputs=2, mini_batch_size = 1, num_iterations=14000
integer, parameter :: num_inputs=2, mini_batch_size = 1, num_iterations=30000
integer batch, iter, i

allocate(harvest(num_inputs, mini_batch_size, num_iterations))
Expand Down Expand Up @@ -228,7 +228,7 @@ function not_and(inputs) result(expected_outputs)

end function

function or_gate_with_symmetric_training_data() result(test_passes)
function or_gate_with_random_weights() result(test_passes)
logical, allocatable :: test_passes(:)
type(mini_batch_t), allocatable :: mini_batches(:)
type(inputs_t), allocatable :: training_inputs(:,:), tmp(:), test_inputs(:)
Expand All @@ -237,7 +237,7 @@ function or_gate_with_symmetric_training_data() result(test_passes)
type(outputs_t), allocatable :: actual_outputs(:)
real(rkind), parameter :: tolerance = 1.E-02_rkind
real(rkind), allocatable :: harvest(:,:,:)
integer, parameter :: num_inputs=2, mini_batch_size = 1, num_iterations=26000
integer, parameter :: num_inputs=2, mini_batch_size = 1, num_iterations=50000
integer batch, iter, i

allocate(harvest(num_inputs, mini_batch_size, num_iterations))
Expand Down Expand Up @@ -271,7 +271,7 @@ function or(inputs) result(expected_outputs)

end function

function xor_gate() result(test_passes)
function xor_gate_with_random_weights() result(test_passes)
logical, allocatable :: test_passes(:)
type(mini_batch_t), allocatable :: mini_batches(:)
type(inputs_t), allocatable :: training_inputs(:,:), tmp(:), test_inputs(:)
Expand All @@ -280,7 +280,7 @@ function xor_gate() result(test_passes)
type(outputs_t), allocatable :: actual_outputs(:)
real(rkind), parameter :: tolerance = 1.E-02_rkind
real(rkind), allocatable :: harvest(:,:,:)
integer, parameter :: num_inputs=2, mini_batch_size = 1, num_iterations=200000
integer, parameter :: num_inputs=2, mini_batch_size = 1, num_iterations=400000
integer batch, iter, i

allocate(harvest(num_inputs, mini_batch_size, num_iterations))
Expand Down

0 comments on commit 7995aca

Please sign in to comment.