jacobian

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit a1a0ecbd96dfe22ae0d39f600da5c20405ca4133
parent 509ec7150cd365ed4387be92f84b6a4090a17a9c
Author: David Freifeld <freifeld.david@gmail.com>
Date:   Mon, 27 Jul 2020 15:23:41 -0700

Update benchmark

Diffstat:
MMakefile | 5++++-
Mbench/benchmark.py | 16++++++++--------
Mbench/scikit.py | 2+-
Mexample.cpp | 24+++++-------------------
Mpictures/runtime.png | 0
5 files changed, 18 insertions(+), 29 deletions(-)

diff --git a/Makefile b/Makefile @@ -17,10 +17,13 @@ all: compile debug: $(GEN_FLAGS) = -Wall -U NDEBUG +test: CXXFLAGS = -std=c++17 example.cpp ./src/bpnn.cpp ./src/utils.cpp mapreduce.a -o bpnnexec -lpthread -lm -ldl -O3 -mavx -mfma -march=native -mfpmath=sse -fno-pic -DMKL_ILP64 -D NDEBUG +test: compile + fast: CXXFLAGS += $(GEN_FLAGS) -O3 fast: compile -faster: CXXFLAGS = -shared -std=c++17 -undefined dynamic_lookup `python3 -m pybind11 --includes` ./src/mr_bpnn_2.cpp ./src/bpnn.cpp ./src/utils.cpp mapreduce.a -o mrbpnn`python3-config --extension-suffix` -O3 -mavx -mfma -march=native -mfpmath=sse -fno-pic -DMKL_ILP64 -D NDEBUG +faster: CXXFLAGS = -shared -std=c++17 -undefined dynamic_lookup `python3 -m pybind11 --includes` ./src/mr_bpnn_2.cpp ./src/bpnn.cpp ./src/utils.cpp mapreduce.a -lpthread -lm -ldl -o mrbpnn`python3-config --extension-suffix` -O3 -mavx -mfma -march=native -mfpmath=sse -fno-pic -DMKL_ILP64 -D NDEBUG faster: compile tradeoffs: CXXFLAGS = -shared -std=c++17 -undefined dynamic_lookup `python3 -m pybind11 --includes` ./src/mr_bpnn_2.cpp ./src/bpnn.cpp ./src/utils.cpp mapreduce.a -o mrbpnn`python3-config --extension-suffix` -O3 -mavx -mfma -march=native -mfpmath=sse -DMKL_ILP64 -qopenmp -fno-pic -qopt-calloc -qopt-prefetch -unroll-aggressive -qopt-calloc -use-intel-optimized-headers -ffast-math -no-prec-div -no-prec-sqrt -fimf-precision=low -fast-transcendentals -D NDEBUG #-qopt-report=5 -qopt-report-file=report diff --git a/bench/benchmark.py b/bench/benchmark.py @@ -43,15 +43,15 @@ for i in range(1): # plt.show() # print(y) -# x = ['Keras', 'Scikit-Learn', 'Jacobian'] -# speed = [3.22842907906, 2.2518157958984375 ,0.043680644035339354] +x = ['Keras', 'Scikit-Learn', 'Jacobian (Python)', 'Jacobian (C++)'] +speed = [4.71297559738, 2.074756145477295,0.05295228958129883, 0.0521543] -# x_pos = [i for i, _ in enumerate(x)] +x_pos = [i for i, _ in enumerate(x)] -# plt.bar(x_pos, speed, color='green') -# plt.ylabel("Time (s)") -# plt.title("Average Runtime (10 trials)") +plt.bar(x_pos, speed, color='green') +plt.ylabel("Time (s)") +plt.title("Runtime for Task") -# plt.xticks(x_pos, x) +plt.xticks(x_pos, x) -# plt.show() +plt.show() diff --git a/bench/scikit.py b/bench/scikit.py @@ -18,7 +18,7 @@ def bench(batch_sz): X_train.append(i[:-1]) y_train.append(i[-1]) - clf = MLPClassifier(solver="sgd", batch_size=batch_sz) + clf = MLPClassifier(solver="sgd", batch_size=batch_sz, hidden_layer_sizes=(5)) clf.fit(X_train, y_train) end = time.time() return end-start diff --git a/example.cpp b/example.cpp @@ -13,31 +13,17 @@ double bench(int batch_sz) { - //auto start = std::chrono::high_resolution_clock::now(); - Network net ("./data_banknote_authentication.txt", batch_sz, 0.05, 0.03, 0, 0.9); + auto start = std::chrono::high_resolution_clock::now(); + Network net ("./data_banknote_authentication.txt", batch_sz, 0.0155, 0.03, 0, 0.9); net.add_layer(4, "linear"); - net.add_layer(6, "relu"); + net.add_layer(5, "relu"); net.add_layer(2, "linear"); - // net.init_decay("step", 1, 2); net.initialize(); - // checks(net); - // for (int i = 0; i < 10; i++) { - // net.next_batch(); - // net.feedforward(); - // net.list_net(); - // net.backpropagate(); - // std::cout << net.cost() << " " << net.accuracy() << "\n"; - // } for (int i = 0; i < 50; i++) { net.train(); - // net.list_net(); } - // std::cout << *net.layers[net.length-1].contents << "\n\n"; - // std::cout << *net.labels << "\n"; - //auto end = std::chrono::high_resolution_clock::now(); - //net.list_net(); - return 0; - //return std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count() / pow(10,9); + auto end = std::chrono::high_resolution_clock::now(); + return std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count() / pow(10,9); } int main() diff --git a/pictures/runtime.png b/pictures/runtime.png Binary files differ.