text
stringlengths
12
786k
let fun11 ( ) = Alcotest . ( check bool ) " fun11 " true ( To_test . fun11 ( ) )
let fun12 ( ) = Alcotest . ( check bool ) " fun12 " true ( To_test . fun12 ( ) )
let fun13 ( ) = Alcotest . ( check bool ) " fun13 " true ( To_test . fun13 ( ) )
let test_set = [ " fun00 " , ` Slow , fun00 ; " fun01 " , ` Slow , fun01 ; " fun02 " , ` Slow , fun02 ; " fun03 " , ` Slow , fun03 ; " fun04 " , ` Slow , fun04 ; " fun05 " , ` Slow , fun05 ; " fun06 " , ` Slow , fun06 ; " fun07 " ...
let close a b = Maths . ( a - b < F 1e - 5 )
let init_ch = [ | F 0 . ; F 0 . ] |
let rate_adagrad = LR . Adagrad 3 .
let rate_rmsprop = LR . RMSprop ( 3 . , 0 . 9 )
let rate_adam = LR . Adam ( 0 . 001 , 0 . 9 , 0 . 999 )
let test_optimiser rate_fun c g x = let ch = init_ch in let _ = Array . mapi ( fun i ci -> ch . ( i ) <- F ci ) c in let c = ref ch in let x = ref ( F x ) in let g = F g in for i = 1 to 3 do c := LR . update_ch rate_fun g ! c ; let lr = LR . run rate_fun i g ! c in x := Maths . ...
module To_test_adagrad = struct let fun00 ( ) = let o = test_optimiser rate_adagrad [ | 0 . 1 ] | 0 . 1 1 . in close o ( F ( - 1 . 6026098728179932 ) ) let fun01 ( ) = let o = test_optimiser rate_adagrad [ | 0 . 1 ] | 0 . 1 2 . in close o ( F ( - 0 . 6...
module To_test_rmsprop = struct let fun00 ( ) = let o = test_optimiser rate_rmsprop [ | 1 . ] | 0 . 1 1 . in close o ( F 2 . 91705132e - 04 ) let fun01 ( ) = let o = test_optimiser rate_rmsprop [ | 1 . ] | 0 . 1 2 . in close o ( F 1 . 00029182 ) let fun02 (...
module To_test_adam = struct let fun00 ( ) = let o = test_optimiser rate_adam [ | 0 . ; 0 . ] | 0 . 1 1 . in close o ( F 0 . 998 ) let fun01 ( ) = let o = test_optimiser rate_adam [ | 0 . ; 0 . ] | 0 . 1 2 . in close o ( F 1 . 998 ) let fun02 ( ) ...
let fun00 ( ) = Alcotest . ( check bool ) " fun00 " true ( To_test_adagrad . fun00 ( ) )
let fun01 ( ) = Alcotest . ( check bool ) " fun01 " true ( To_test_adagrad . fun01 ( ) )
let fun02 ( ) = Alcotest . ( check bool ) " fun02 " true ( To_test_adagrad . fun02 ( ) )
let fun03 ( ) = Alcotest . ( check bool ) " fun03 " true ( To_test_adagrad . fun03 ( ) )
let fun04 ( ) = Alcotest . ( check bool ) " fun04 " true ( To_test_rmsprop . fun00 ( ) )
let fun05 ( ) = Alcotest . ( check bool ) " fun05 " true ( To_test_rmsprop . fun01 ( ) )
let fun06 ( ) = Alcotest . ( check bool ) " fun06 " true ( To_test_rmsprop . fun02 ( ) )
let fun07 ( ) = Alcotest . ( check bool ) " fun07 " true ( To_test_rmsprop . fun03 ( ) )
let fun08 ( ) = Alcotest . ( check bool ) " fun08 " true ( To_test_adam . fun00 ( ) )
let fun09 ( ) = Alcotest . ( check bool ) " fun09 " true ( To_test_adam . fun01 ( ) )
let fun10 ( ) = Alcotest . ( check bool ) " fun10 " true ( To_test_adam . fun02 ( ) )
let fun11 ( ) = Alcotest . ( check bool ) " fun11 " true ( To_test_adam . fun03 ( ) )
let test_set = [ " fun00 " , ` Slow , fun00 ; " fun01 " , ` Slow , fun01 ; " fun02 " , ` Slow , fun02 ; " fun03 " , ` Slow , fun03 ; " fun04 " , ` Slow , fun04 ; " fun05 " , ` Slow , fun05 ; " fun06 " , ` Slow , fun06 ; " fun07 " ...
let approx_equal a b = let eps = 1e - 6 in Stdlib . ( abs_float ( a . - b ) < eps )
let x0 = Mat . sequential ~ a : 1 . 1 6
let x1 = Mat . sequential ~ a : 1 . 3 3
module To_test = struct let rank ( ) = let x = Mat . sequential 4 4 in M . rank x = 2 let det ( ) = let x = Mat . hadamard 4 in M . det x = 16 . let inv ( ) = let x = Mat . hadamard 4 in M . inv x |> Mat . sum ' = 1 . let vecnorm_01 ( ) = let a = M . vecnorm ~ ...
let rank ( ) = Alcotest . ( check bool ) " rank " true ( To_test . rank ( ) )
let det ( ) = Alcotest . ( check bool ) " det " true ( To_test . det ( ) )
let inv ( ) = Alcotest . ( check bool ) " inv " true ( To_test . inv ( ) )
let vecnorm_01 ( ) = Alcotest . ( check bool ) " vecnorm_01 " true ( To_test . vecnorm_01 ( ) )
let vecnorm_02 ( ) = Alcotest . ( check bool ) " vecnorm_02 " true ( To_test . vecnorm_02 ( ) )
let vecnorm_03 ( ) = Alcotest . ( check bool ) " vecnorm_03 " true ( To_test . vecnorm_03 ( ) )
let vecnorm_04 ( ) = Alcotest . ( check bool ) " vecnorm_04 " true ( To_test . vecnorm_04 ( ) )
let vecnorm_05 ( ) = Alcotest . ( check bool ) " vecnorm_05 " true ( To_test . vecnorm_05 ( ) )
let vecnorm_06 ( ) = Alcotest . ( check bool ) " vecnorm_06 " true ( To_test . vecnorm_06 ( ) )
let vecnorm_07 ( ) = Alcotest . ( check bool ) " vecnorm_07 " true ( To_test . vecnorm_07 ( ) )
let vecnorm_08 ( ) = Alcotest . ( check bool ) " vecnorm_08 " true ( To_test . vecnorm_08 ( ) )
let vecnorm_09 ( ) = Alcotest . ( check bool ) " vecnorm_09 " true ( To_test . vecnorm_09 ( ) )
let vecnorm_10 ( ) = Alcotest . ( check bool ) " vecnorm_10 " true ( To_test . vecnorm_10 ( ) )
let norm_01 ( ) = Alcotest . ( check bool ) " norm_01 " true ( To_test . norm_01 ( ) )
let norm_02 ( ) = Alcotest . ( check bool ) " norm_02 " true ( To_test . norm_02 ( ) )
let norm_03 ( ) = Alcotest . ( check bool ) " norm_03 " true ( To_test . norm_03 ( ) )
let norm_04 ( ) = Alcotest . ( check bool ) " norm_04 " true ( To_test . norm_04 ( ) )
let norm_05 ( ) = Alcotest . ( check bool ) " norm_05 " true ( To_test . norm_05 ( ) )
let norm_06 ( ) = Alcotest . ( check bool ) " norm_06 " true ( To_test . norm_06 ( ) )
let is_triu_1 ( ) = Alcotest . ( check bool ) " is_triu_1 " true ( To_test . is_triu_1 ( ) )
let is_triu_2 ( ) = Alcotest . ( check bool ) " is_triu_2 " true ( To_test . is_triu_2 ( ) )
let is_tril_1 ( ) = Alcotest . ( check bool ) " is_tril_1 " true ( To_test . is_tril_1 ( ) )
let is_tril_2 ( ) = Alcotest . ( check bool ) " is_tril_2 " true ( To_test . is_tril_2 ( ) )
let is_symmetric_1 ( ) = Alcotest . ( check bool ) " is_symmetric_1 " true ( To_test . is_symmetric_1 ( ) )
let is_symmetric_2 ( ) = Alcotest . ( check bool ) " is_symmetric_2 " true ( To_test . is_symmetric_2 ( ) )
let is_diag_1 ( ) = Alcotest . ( check bool ) " is_diag_1 " true ( To_test . is_diag_1 ( ) )
let is_diag_2 ( ) = Alcotest . ( check bool ) " is_diag_2 " true ( To_test . is_diag_2 ( ) )
let mpow ( ) = Alcotest . ( check bool ) " mpow " true ( To_test . mpow ( ) )
let expm_1 ( ) = Alcotest . ( check bool ) " expm_1 " true ( To_test . expm_1 ( ) )
let expm_2 ( ) = Alcotest . ( check bool ) " expm_2 " true ( To_test . expm_2 ( ) )
let expm_3 ( ) = Alcotest . ( check bool ) " expm_3 " true ( To_test . expm_3 ( ) )
let expm_4 ( ) = Alcotest . ( check bool ) " expm_4 " true ( To_test . expm_4 ( ) )
let sinm ( ) = Alcotest . ( check bool ) " sinm " true ( To_test . sinm ( ) )
let cosm ( ) = Alcotest . ( check bool ) " cosm " true ( To_test . cosm ( ) )
let tanm ( ) = Alcotest . ( check bool ) " tanm " true ( To_test . tanm ( ) )
let sincosm ( ) = Alcotest . ( check bool ) " sincosm " true ( To_test . sincosm ( ) )
let sinhm ( ) = Alcotest . ( check bool ) " sinhm " true ( To_test . sinhm ( ) )
let coshm ( ) = Alcotest . ( check bool ) " coshm " true ( To_test . coshm ( ) )
let tanhm ( ) = Alcotest . ( check bool ) " tanhm " true ( To_test . tanhm ( ) )
let sinhcoshm ( ) = Alcotest . ( check bool ) " sinhcoshm " true ( To_test . sinhcoshm ( ) )
let test_set = [ " rank " , ` Slow , rank ; " det " , ` Slow , det ; " inv " , ` Slow , inv ; " vecnorm_01 " , ` Slow , vecnorm_01 ; " vecnorm_02 " , ` Slow , vecnorm_02 ; " vecnorm_03 " , ` Slow , vecnorm_03 ; " vecnorm_04 " , ` Slow , ...
let approx_equal a b = let eps = 1e - 5 in N . approx_equal ~ eps a b
module To_test_gauss = struct let test01 ( ) = let a = N . of_array [ | 1 . ; 20 . ; - 30 . ; 4 . ] | [ | 2 ; 2 ] | in let b = N . of_array [ | 1 . ; 0 . ; 1 . ; 2 . ; - 30 . ; 0 . ; 1 . ; 0 . ; 1 . ; 4 . ] | [ | 2 ...
module To_test_lu = struct let perm_vec_to_mat vec = let n = Array . length vec in let mat = ref ( M . eye n ) in for i = n - 1 downto 0 do let j = vec . ( i ) in let a = M . eye n in N . set a [ | i ; i ] | 0 . ; N . set a [ | j ; j ] | 0 . ; N . set a [ | i...
module To_test_bandiag = struct let _test_tridiag n = let a = N . uniform [ | n ] | in let trimat = N . zeros [ | n ; n ] | in let a_vec = Array . make n 0 . in for i = 1 to n - 1 do let v = N . get a [ | i ] | in a_vec . ( i ) <- v ; N . set trimat [ | i ; i -...
let test_gauss_01 ( ) = Alcotest . ( check bool ) " test_guass_01 " true ( To_test_gauss . test01 ( ) )
let test_gauss_02 ( ) = Alcotest . ( check bool ) " test_guass_02 " true ( To_test_gauss . test02 ( ) )
let test_gauss_03 ( ) = Alcotest . ( check bool ) " test_guass_03 " true ( To_test_gauss . test03 ( ) )
let test_gauss_04 ( ) = Alcotest . ( check bool ) " test_guass_04 " true ( To_test_gauss . test04 ( ) )
let test_lu_01 ( ) = Alcotest . ( check bool ) " test_lu_01 " true ( To_test_lu . test01 ( ) )
let test_lu_02 ( ) = Alcotest . ( check bool ) " test_lu_02 " true ( To_test_lu . test02 ( ) )
let test_lu_03 ( ) = Alcotest . ( check bool ) " test_lu_03 " true ( To_test_lu . test03 ( ) )
let test_lu_04 ( ) = Alcotest . ( check bool ) " test_lu_04 " true ( To_test_lu . test04 ( ) )
let test_lu_05 ( ) = Alcotest . ( check bool ) " test_lu_05 " true ( To_test_lu . test05 ( ) )
let test_lu_06 ( ) = Alcotest . ( check bool ) " test_lu_06 " true ( To_test_lu . test06 ( ) )
let test_lu_07 ( ) = Alcotest . ( check bool ) " test_lu_07 " true ( To_test_lu . test07 ( ) )
let test_lu_08 ( ) = Alcotest . ( check bool ) " test_lu_08 " true ( To_test_lu . test08 ( ) )
let test_lu_09 ( ) = Alcotest . ( check bool ) " test_lu_09 " true ( To_test_lu . test09 ( ) )
let test_lu_10 ( ) = Alcotest . ( check bool ) " test_lu_10 " true ( To_test_lu . test10 ( ) )
let test_bandiag_01 ( ) = Alcotest . ( check bool ) " To_test_bandiag_01 " true ( To_test_bandiag . test01 ( ) )
let test_set = [ " test_gauss_01 " , ` Slow , test_gauss_01 ; " test_gauss_02 " , ` Slow , test_gauss_02 ; " test_gauss_03 " , ` Slow , test_gauss_03 ; " test_gauss_04 " , ` Slow , test_gauss_04 ; " test_lu_01 " , ` Slow , test_lu_01 ; " test_lu_02 " , ...
let approx_equal a b = Stdlib . ( abs_float ( a . - b ) < eps )
module To_test = struct let test_j0 ( ) = approx_equal ( M . j0 0 . 5 ) 0 . 93846980724081297 let test_j1 ( ) = approx_equal ( M . j1 0 . 5 ) 0 . 24226845767487387 let test_jv ( ) = approx_equal ( M . jv 0 . 1 0 . 3 ) 0 . 85180759557596664 let test_y0 ( ) ...
let test_j0 ( ) = Alcotest . ( check bool ) " test j0 " true ( To_test . test_j0 ( ) )
let test_j1 ( ) = Alcotest . ( check bool ) " test j1 " true ( To_test . test_j1 ( ) )
let test_jv ( ) = Alcotest . ( check bool ) " test jv " true ( To_test . test_jv ( ) )
let test_y0 ( ) = Alcotest . ( check bool ) " test y0 " true ( To_test . test_y0 ( ) )
let test_y1 ( ) = Alcotest . ( check bool ) " test y1 " true ( To_test . test_y1 ( ) )
let test_yv ( ) = Alcotest . ( check bool ) " test yv " true ( To_test . test_yv ( ) )
let test_i0 ( ) = Alcotest . ( check bool ) " test i0 " true ( To_test . test_i0 ( ) )