diff options
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | tests/architectures/big_nn.cfg | 20 | ||||
-rw-r--r-- | tests/architectures/gauss1d.cfg | 16 | ||||
-rw-r--r-- | tests/architectures/xor.cfg | 16 | ||||
-rw-r--r-- | tests/main.sh | 10 | ||||
-rw-r--r-- | tests/plots.gpi | 37 |
6 files changed, 102 insertions, 1 deletions
@@ -7,5 +7,7 @@ doc/* !doc/*.tex !doc/*.1 *.gdb -*.gpi +utils/*.gpi *.bin +utils/*.py +tests/*.png diff --git a/tests/architectures/big_nn.cfg b/tests/architectures/big_nn.cfg new file mode 100644 index 0000000..a7b90a5 --- /dev/null +++ b/tests/architectures/big_nn.cfg @@ -0,0 +1,20 @@ +[net] +loss = square ; options (square) +epochs = 1000 ; comment +alpha = 1e-6 +weights_path = data/big_nn.bin +inputs = x,y +labels = z + +; activation options (relu, sigmoid, softplus, leaky_relu) + +[layer] +neurons=20 +activation=relu + +[layer] +neurons=20 +activation=relu + +[outlayer] +activation = sigmoid diff --git a/tests/architectures/gauss1d.cfg b/tests/architectures/gauss1d.cfg new file mode 100644 index 0000000..db1601d --- /dev/null +++ b/tests/architectures/gauss1d.cfg @@ -0,0 +1,16 @@ +[net] +loss = square ; options (square) +epochs = 1000 ; comment +alpha = 1e-2 +weights_path = data/gauss1d.bin +inputs = x +labels = y + +; activation options (relu, sigmoid, softplus, leaky_relu) + +[layer] +neurons=10 +activation=sigmoid + +[outlayer] +activation = sigmoid diff --git a/tests/architectures/xor.cfg b/tests/architectures/xor.cfg new file mode 100644 index 0000000..e0b06d4 --- /dev/null +++ b/tests/architectures/xor.cfg @@ -0,0 +1,16 @@ +[net] +loss = square ; options (square) +epochs = 1000 ; comment +alpha = 0.05 +weights_path = data/xor.bin +inputs = x,y +labels = z + +; activation options (relu, sigmoid, softplus, leaky_relu) + +[layer] +neurons=10 +activation=relu + +[outlayer] +activation = sigmoid diff --git a/tests/main.sh b/tests/main.sh new file mode 100644 index 0000000..7224f79 --- /dev/null +++ b/tests/main.sh @@ -0,0 +1,10 @@ +#!/usr/bin/bash +echo 'Network Accuraccy' +echo '-----------------' +gnuplot tests/plots.gpi +echo '' + +echo 'Benchmark test' +echo '-------------------' +time ./ml train -c tests/architectures/big_nn.cfg data/gauss2d.json > /dev/null +echo '' diff --git a/tests/plots.gpi b/tests/plots.gpi new file mode 100644 index 0000000..85fbf98 --- /dev/null +++ b/tests/plots.gpi @@ -0,0 +1,37 @@ +#!/usr/bin/gnuplot +set term pngcairo size 1080,720 +set output 'tests/network_accuracy.png' +set multiplot layout 2, 2 +set grid + +json2tsv = "jq -r '.[] | [.[]] | @tsv' %s" +train_cmd = "<./ml train %s -c %s" +predict_cmd = "<./ml predict %s -c %s | ".sprintf(json2tsv, "-") + +# -- +data_gauss1d = "data/gauss1d.json" +data_xor = "data/xor.json" + +# -- +arch_gauss1d = "tests/architectures/gauss1d.cfg" +arch_xor = "tests/architectures/xor.cfg" + + +set ylabel arch_gauss1d +set logscale x +plot sprintf(train_cmd, data_gauss1d, arch_gauss1d) u 2:4 with lines title 'loss' +unset logscale +unset ylabel + +plot sprintf(predict_cmd, data_gauss1d, arch_gauss1d) with lines title 'network',\ + "<".sprintf(json2tsv, data_gauss1d) with lines title 'original' + +set ylabel arch_xor +set logscale x +plot sprintf(train_cmd, data_xor, arch_xor) u 2:4 with lines title 'loss' +unset logscale +unset ylabel + +set table "/dev/stdout" +plot "<".sprintf(json2tsv, data_xor) using 1:2:3 with table,\ + sprintf(predict_cmd, data_xor, arch_xor) using 3 with table |