From 18cc40f519410c062fe639c6ade7ff8411f31219 Mon Sep 17 00:00:00 2001 From: Jan Kessler Date: Tue, 16 Apr 2019 22:29:37 +0200 Subject: [PATCH] Adapt some script changes from other libs, give proper names to example folders, add CLion .idea files. --- .gitignore | 22 ++++++ .idea/.name | 1 + .idea/FeedForwardNeuralNetwork.iml | 2 + .idea/codeStyles/Project.xml | 67 +++++++++++++++++++ .idea/codeStyles/codeStyleConfig.xml | 5 ++ .idea/encodings.xml | 4 ++ .idea/inspectionProfiles/Project_Default.xml | 11 +++ .../inspectionProfiles/profiles_settings.xml | 7 ++ .idea/misc.xml | 29 ++++++++ .idea/modules.xml | 8 +++ .idea/vcs.xml | 6 ++ benchmark/run.sh | 2 +- benchmark/run_prof.sh | 10 +-- examples/CMakeLists.txt | 20 +++--- examples/README.md | 40 +++++------ examples/ex5/run.sh | 3 - examples/ex6/run.sh | 3 - examples/ex7/run.sh | 3 - examples/{ex3 => ex_actf}/main.cpp | 0 examples/{ex1 => ex_actf}/run.sh | 2 +- examples/{ex1 => ex_basic}/main.cpp | 0 examples/{ex3 => ex_basic}/run.sh | 2 +- examples/{ex2 => ex_beta}/main.cpp | 0 examples/{ex4 => ex_beta}/run.sh | 2 +- examples/{ex10 => ex_features}/main.cpp | 0 examples/{ex10 => ex_features}/plot.py | 0 examples/{ex10 => ex_features}/run.sh | 2 +- examples/{ex9 => ex_fit}/main.cpp | 0 examples/{ex9 => ex_fit}/plot.py | 0 examples/{ex9 => ex_fit}/run.sh | 2 +- examples/{ex8 => ex_loadfile}/main.cpp | 0 examples/{ex8 => ex_loadfile}/run.sh | 2 +- examples/{ex8 => ex_loadfile}/stored_ffnn.txt | 0 examples/{ex7 => ex_plot}/main.cpp | 0 examples/{ex2 => ex_plot}/run.sh | 2 +- examples/{ex4 => ex_propagate}/main.cpp | 0 examples/ex_propagate/run.sh | 3 + examples/{ex6 => ex_vderiv}/main.cpp | 0 examples/ex_vderiv/run.sh | 3 + examples/{ex5 => ex_xderiv}/main.cpp | 0 examples/ex_xderiv/run.sh | 3 + test/run.sh | 2 +- 42 files changed, 216 insertions(+), 52 deletions(-) create mode 100644 .idea/.name create mode 100644 .idea/FeedForwardNeuralNetwork.iml create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml delete mode 100755 examples/ex5/run.sh delete mode 100755 examples/ex6/run.sh delete mode 100755 examples/ex7/run.sh rename examples/{ex3 => ex_actf}/main.cpp (100%) rename examples/{ex1 => ex_actf}/run.sh (70%) rename examples/{ex1 => ex_basic}/main.cpp (100%) rename examples/{ex3 => ex_basic}/run.sh (69%) rename examples/{ex2 => ex_beta}/main.cpp (100%) rename examples/{ex4 => ex_beta}/run.sh (70%) rename examples/{ex10 => ex_features}/main.cpp (100%) rename examples/{ex10 => ex_features}/plot.py (100%) rename examples/{ex10 => ex_features}/run.sh (74%) rename examples/{ex9 => ex_fit}/main.cpp (100%) rename examples/{ex9 => ex_fit}/plot.py (100%) rename examples/{ex9 => ex_fit}/run.sh (80%) rename examples/{ex8 => ex_loadfile}/main.cpp (100%) rename examples/{ex8 => ex_loadfile}/run.sh (80%) rename examples/{ex8 => ex_loadfile}/stored_ffnn.txt (100%) rename examples/{ex7 => ex_plot}/main.cpp (100%) rename examples/{ex2 => ex_plot}/run.sh (70%) rename examples/{ex4 => ex_propagate}/main.cpp (100%) create mode 100755 examples/ex_propagate/run.sh rename examples/{ex6 => ex_vderiv}/main.cpp (100%) create mode 100755 examples/ex_vderiv/run.sh rename examples/{ex5 => ex_xderiv}/main.cpp (100%) create mode 100755 examples/ex_xderiv/run.sh diff --git a/.gitignore b/.gitignore index f3e149f..5df6aa1 100644 --- a/.gitignore +++ b/.gitignore @@ -58,6 +58,28 @@ xcuserdata DerivedData *.xcuserstate +# --- JetBrains Clion files (selective) +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf +.idea/**/contentModel.xml +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml +.idea/**/gradle.xml +.idea/**/libraries +.idea/**/mongoSettings.xml +.idea_modules/ +.idea/replstate.xml +.idea/httpRequests + + # -- project specific ignores -- lib* build diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..cba4e1d --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +ffnn \ No newline at end of file diff --git a/.idea/FeedForwardNeuralNetwork.iml b/.idea/FeedForwardNeuralNetwork.iml new file mode 100644 index 0000000..f08604b --- /dev/null +++ b/.idea/FeedForwardNeuralNetwork.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..eca96b9 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,67 @@ + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..15a15b2 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..0b04902 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,11 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..dd4c951 --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..e7d8df2 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + C/C++ + + + + + C/C++ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..eb7e75f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/benchmark/run.sh b/benchmark/run.sh index f220260..78b4ebf 100755 --- a/benchmark/run.sh +++ b/benchmark/run.sh @@ -3,7 +3,7 @@ if [ "$1" = "" ]; then echo "Expected the name of the benchmark to run as first argument." else - bench=$1 + bench=${1%"/"} # remove any trailing / outfile="$(pwd)/${bench}/benchmark_new.out" cd ../build/benchmark/ echo diff --git a/benchmark/run_prof.sh b/benchmark/run_prof.sh index 6460068..9cdbc66 100755 --- a/benchmark/run_prof.sh +++ b/benchmark/run_prof.sh @@ -2,15 +2,17 @@ if [ "$1" = "" ]; then echo "Expected the name of the benchmark to run as first argument." -elif [ "$2" = "" ]; then - echo "Expected the path of libprofiler.so as second argument." else - bench=$1 + bench=${1%"/"} # remove any trailing / lprof=$2 + if [ "$lprof" = "" ]; then + echo "Using default libprofiler.so path: /usr/lib/libprofiler.so" + lprof="/usr/lib/libprofiler.so" + fi; cd ../build/benchmark/ echo echo "Running benchmark ${bench}..." LD_PRELOAD=${lprof} CPUPROFILE=${bench}.prof CPUPROFILE_FREQUENCY=10000 CPUPROFILE_REALTIME=1 ./${bench} pprof --text ${bench} ${bench}.prof echo -fi +fi; diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 7dfe385..58781cf 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,12 +1,12 @@ link_libraries(ffnn) -add_executable(ex1.exe ex1/main.cpp) -add_executable(ex2.exe ex2/main.cpp) -add_executable(ex3.exe ex3/main.cpp) -add_executable(ex4.exe ex4/main.cpp) -add_executable(ex5.exe ex5/main.cpp) -add_executable(ex6.exe ex6/main.cpp) -add_executable(ex7.exe ex7/main.cpp) -add_executable(ex8.exe ex8/main.cpp) -add_executable(ex9.exe ex9/main.cpp) -add_executable(ex10.exe ex10/main.cpp) +add_executable(ex_basic.exe ex_basic/main.cpp) +add_executable(ex_beta.exe ex_beta/main.cpp) +add_executable(ex_actf.exe ex_actf/main.cpp) +add_executable(ex_propagate.exe ex_propagate/main.cpp) +add_executable(ex_xderiv.exe ex_xderiv/main.cpp) +add_executable(ex_vderiv.exe ex_vderiv/main.cpp) +add_executable(ex_plot.exe ex_plot/main.cpp) +add_executable(ex_loadfile.exe ex_loadfile/main.cpp) +add_executable(ex_fit.exe ex_fit/main.cpp) +add_executable(ex_features.exe ex_features/main.cpp) diff --git a/examples/README.md b/examples/README.md index 974ff41..22218b1 100644 --- a/examples/README.md +++ b/examples/README.md @@ -7,60 +7,60 @@ Some examples might also contain a `plot.py` script to show a plot. It gets call by `./run.sh` after the executable has terminated, but requires python with matplotlib. -## Example 1 +## Basic Example -`ex1/`: construct and modify the geometry of a FFNN (i.e. number of layers and units) +`ex_basic/`: construct and modify the geometry of a FFNN (i.e. number of layers and units) -## Example 2 +## Network weights (beta) -`ex2/`: access and modify the beta of a FFNN (i.e. the variational parameters) +`ex_beta/`: access and modify the beta of a FFNN (i.e. the variational parameters) -## Example 3 +## Activation Functions -`ex3/`: manage the activation functions +`ex_actf/`: manage the activation functions -## Example 4 +## NN Propagation -`ex4/`: compute the output of a FFNN +`ex_propagate/`: compute the output of a FFNN -## Example 5 +## Input Derivative -`ex5/`: compute first and second derivative of the NN output in respect to input +`ex_xderiv/`: compute first and second derivative of the NN output in respect to input -## Example 6 +## Variational Derivative -`ex6/`: compute first derivative of the NN in respect to the variational parameters (betas) +`ex_vderiv/`: compute first derivative of the NN in respect to the variational parameters (betas) -## Example 7 +## Printing and Plotting -`ex7/`: write files for plotting the values and its first and second derivatives of a NN:R->R (1-dimensional function) +`ex_plot/`: write files for plotting the values and its first and second derivatives of a NN:R->R (1-dimensional function) -## Example 8 +## Load NN from file -`ex8/`: read FFNN structure from a file +`ex_loadfile/`: read FFNN structure from a file -## Example 9 +## Fit NN function to data -`ex9/`: use NNTrainer(GSL) to make FFNN fit a gaussian +`ex_fit/`: use NNTrainer(GSL) to make FFNN fit a gaussian -## Example 10 +## Fit a NN with feature map layer -`ex10/`: use a FeatureMapLayer to fit more easily a gaussian of x-y-distance +`ex_features/`: use a FeatureMapLayer to fit more easily a gaussian of x-y-distance diff --git a/examples/ex5/run.sh b/examples/ex5/run.sh deleted file mode 100755 index 943d004..0000000 --- a/examples/ex5/run.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -cd ../../build/examples -./ex5.exe diff --git a/examples/ex6/run.sh b/examples/ex6/run.sh deleted file mode 100755 index 0a25c76..0000000 --- a/examples/ex6/run.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -cd ../../build/examples -./ex6.exe diff --git a/examples/ex7/run.sh b/examples/ex7/run.sh deleted file mode 100755 index d4186f5..0000000 --- a/examples/ex7/run.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -cd ../../build/examples -./ex7.exe diff --git a/examples/ex3/main.cpp b/examples/ex_actf/main.cpp similarity index 100% rename from examples/ex3/main.cpp rename to examples/ex_actf/main.cpp diff --git a/examples/ex1/run.sh b/examples/ex_actf/run.sh similarity index 70% rename from examples/ex1/run.sh rename to examples/ex_actf/run.sh index 315481f..9730cd6 100755 --- a/examples/ex1/run.sh +++ b/examples/ex_actf/run.sh @@ -1,3 +1,3 @@ #!/bin/sh cd ../../build/examples -./ex1.exe +./ex_actf.exe diff --git a/examples/ex1/main.cpp b/examples/ex_basic/main.cpp similarity index 100% rename from examples/ex1/main.cpp rename to examples/ex_basic/main.cpp diff --git a/examples/ex3/run.sh b/examples/ex_basic/run.sh similarity index 69% rename from examples/ex3/run.sh rename to examples/ex_basic/run.sh index 3b42d77..aa4d6f3 100755 --- a/examples/ex3/run.sh +++ b/examples/ex_basic/run.sh @@ -1,3 +1,3 @@ #!/bin/sh cd ../../build/examples -./ex3.exe +./ex_basic.exe diff --git a/examples/ex2/main.cpp b/examples/ex_beta/main.cpp similarity index 100% rename from examples/ex2/main.cpp rename to examples/ex_beta/main.cpp diff --git a/examples/ex4/run.sh b/examples/ex_beta/run.sh similarity index 70% rename from examples/ex4/run.sh rename to examples/ex_beta/run.sh index 3e7aba3..b84ca52 100755 --- a/examples/ex4/run.sh +++ b/examples/ex_beta/run.sh @@ -1,3 +1,3 @@ #!/bin/sh cd ../../build/examples -./ex4.exe +./ex_beta.exe diff --git a/examples/ex10/main.cpp b/examples/ex_features/main.cpp similarity index 100% rename from examples/ex10/main.cpp rename to examples/ex_features/main.cpp diff --git a/examples/ex10/plot.py b/examples/ex_features/plot.py similarity index 100% rename from examples/ex10/plot.py rename to examples/ex_features/plot.py diff --git a/examples/ex10/run.sh b/examples/ex_features/run.sh similarity index 74% rename from examples/ex10/run.sh rename to examples/ex_features/run.sh index 7365751..b0b3da1 100755 --- a/examples/ex10/run.sh +++ b/examples/ex_features/run.sh @@ -1,6 +1,6 @@ #!/bin/sh ( cd ../../build/examples -./ex10.exe +./ex_features.exe ) python plot.py diff --git a/examples/ex9/main.cpp b/examples/ex_fit/main.cpp similarity index 100% rename from examples/ex9/main.cpp rename to examples/ex_fit/main.cpp diff --git a/examples/ex9/plot.py b/examples/ex_fit/plot.py similarity index 100% rename from examples/ex9/plot.py rename to examples/ex_fit/plot.py diff --git a/examples/ex9/run.sh b/examples/ex_fit/run.sh similarity index 80% rename from examples/ex9/run.sh rename to examples/ex_fit/run.sh index 973b4b4..9e6afc9 100755 --- a/examples/ex9/run.sh +++ b/examples/ex_fit/run.sh @@ -1,6 +1,6 @@ #!/bin/sh ( cd ../../build/examples -./ex9.exe +./ex_fit.exe ) python plot.py diff --git a/examples/ex8/main.cpp b/examples/ex_loadfile/main.cpp similarity index 100% rename from examples/ex8/main.cpp rename to examples/ex_loadfile/main.cpp diff --git a/examples/ex8/run.sh b/examples/ex_loadfile/run.sh similarity index 80% rename from examples/ex8/run.sh rename to examples/ex_loadfile/run.sh index 708394e..fffdf27 100755 --- a/examples/ex8/run.sh +++ b/examples/ex_loadfile/run.sh @@ -1,4 +1,4 @@ #!/bin/sh cp stored_ffnn.txt ../../build/examples/ cd ../../build/examples -./ex8.exe +./ex_loadfile.exe diff --git a/examples/ex8/stored_ffnn.txt b/examples/ex_loadfile/stored_ffnn.txt similarity index 100% rename from examples/ex8/stored_ffnn.txt rename to examples/ex_loadfile/stored_ffnn.txt diff --git a/examples/ex7/main.cpp b/examples/ex_plot/main.cpp similarity index 100% rename from examples/ex7/main.cpp rename to examples/ex_plot/main.cpp diff --git a/examples/ex2/run.sh b/examples/ex_plot/run.sh similarity index 70% rename from examples/ex2/run.sh rename to examples/ex_plot/run.sh index d2054c1..9c95575 100755 --- a/examples/ex2/run.sh +++ b/examples/ex_plot/run.sh @@ -1,3 +1,3 @@ #!/bin/sh cd ../../build/examples -./ex2.exe +./ex_plot.exe diff --git a/examples/ex4/main.cpp b/examples/ex_propagate/main.cpp similarity index 100% rename from examples/ex4/main.cpp rename to examples/ex_propagate/main.cpp diff --git a/examples/ex_propagate/run.sh b/examples/ex_propagate/run.sh new file mode 100755 index 0000000..0c8797a --- /dev/null +++ b/examples/ex_propagate/run.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cd ../../build/examples +./ex_propagate.exe diff --git a/examples/ex6/main.cpp b/examples/ex_vderiv/main.cpp similarity index 100% rename from examples/ex6/main.cpp rename to examples/ex_vderiv/main.cpp diff --git a/examples/ex_vderiv/run.sh b/examples/ex_vderiv/run.sh new file mode 100755 index 0000000..df14823 --- /dev/null +++ b/examples/ex_vderiv/run.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cd ../../build/examples +./ex_vderiv.exe diff --git a/examples/ex5/main.cpp b/examples/ex_xderiv/main.cpp similarity index 100% rename from examples/ex5/main.cpp rename to examples/ex_xderiv/main.cpp diff --git a/examples/ex_xderiv/run.sh b/examples/ex_xderiv/run.sh new file mode 100755 index 0000000..ce3b098 --- /dev/null +++ b/examples/ex_xderiv/run.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cd ../../build/examples +./ex_xderiv.exe diff --git a/test/run.sh b/test/run.sh index cdd0266..4eca60f 100755 --- a/test/run.sh +++ b/test/run.sh @@ -7,6 +7,6 @@ ${VALGRIND} ./check for exe in ./ut*.exe; do echo echo "Running test ${exe}..." - ${VALGRIND} ${exe} + ${VALGRIND} ${exe} || exit 1 echo done