jacobian

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

commit 58dab65b73329cbb51485c00b420846b8445785f
parent 9d0599d64aba88854b603dbc39aadc7a262729d4
Author: David Freifeld <freifeld.david@gmail.com>
Date:   Fri,  3 Jul 2020 22:58:03 -0700

Updated scripts to try and work w/ strassen

Diffstat:
Abenchmark.py | 31+++++++++++++++++++++++++++++++
Mexample.cpp | 7++++++-
Mexample.py | 33---------------------------------
3 files changed, 37 insertions(+), 34 deletions(-)

diff --git a/benchmark.py b/benchmark.py @@ -0,0 +1,31 @@ +import mrbpnn +import matplotlib.pyplot as plt +import numpy +import time + +def bench(batch_sz, layers): + init = time.time() + net = mrbpnn.Network("./data_banknote_authentication.txt", batch_sz, 0.0155, 0.03, 0.9) + net.add_layer(4, "linear") + for i in range(layers): + net.add_layer(5, "relu") + net.add_layer(1, "resig") + net.initialize() + initend = time.time() + net.train(50) + end = time.time() + return (end-init) + +x = [] +y = [] +i = 1 +while(i < 1340): + print(i) + y.append(bench(i, 1)) + x.append(i) + i+=1; +plt.plot(x,y, label = "ML-in-Parallel (Sequential)") + +# plt.plot(otherlist, [2.3994078636169434, 1.2735769748687744, 1.0030598640441895, 0.8972160816192627, 0.801548957824707, 0.752018928527832, 0.7073678970336914, 0.6857280731201172, 0.6707980632781982, 0.6421489715576172, 0.6614980697631836, 0.6403779983520508, 0.7251319885253906, 0.6796879768371582, 0.6601080894470215, 0.6711599826812744, 0.6432759761810303, 0.6491389274597168, 0.6762490272521973, 0.6859049797058105, 0.7067179679870605, 0.7142889499664307, 0.7258059978485107, 0.7868969440460205, 0.7326970100402832, 0.7365641593933105, 0.7576079368591309, 0.7772500514984131, 0.8062641620635986, 0.7768490314483643, 0.8253629207611084, 0.8264601230621338, 0.8459320068359375, 0.9670729637145996, 0.8388969898223877, 0.9129719734191895, 0.9009649753570557, 0.8916170597076416, 0.8926799297332764, 0.9171609878540039, 0.9242072105407715, 0.9534740447998047, 0.947465181350708, 0.9723358154296875, 1.018247127532959, 1.1208629608154297, 1.014026165008545, 1.034980058670044, 1.0626468658447266, 1.080394983291626, 1.0627479553222656, 1.0839190483093262, 1.0938241481781006, 1.127730131149292, 1.1265759468078613, 1.136888027191162, 1.140428066253662, 1.1712510585784912, 1.206390142440796, 1.2087180614471436, 1.4066569805145264, 1.2425589561462402, 1.280066967010498, 1.2891559600830078, 1.3243582248687744, 1.3152379989624023], label="Keras") +plt.legend() +plt.show() diff --git a/example.cpp b/example.cpp @@ -13,10 +13,15 @@ double bench(int batch_sz) net.initialize(); net.train(50); auto end = std::chrono::high_resolution_clock::now(); + // net.list_net(); return std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count() / pow(10,9); } int main() { - bench(10); + bench(50); + bench(50); + bench(50); + bench(50); + bench(50); } diff --git a/example.py b/example.py @@ -4,36 +4,6 @@ import matplotlib.pyplot as plt import numpy import time import wandb -from viznet import NodeBrush, EdgeBrush, DynamicShow - -def draw_feed_forward(ax, num_node_list): - ''' - draw a feed forward neural network. - - Args: - num_node_list (list<int>): number of nodes in each layer. - ''' - num_hidden_layer = len(num_node_list) - 2 - token_list = ['\sigma^z'] + \ - ['y^{(%s)}' % (i + 1) for i in range(num_hidden_layer)] + ['\psi'] - kind_list = ['nn.input'] + ['nn.hidden'] * num_hidden_layer + ['nn.output'] - radius_list = [0.3] + [0.2] * num_hidden_layer + [0.3] - y_list = 1.5 * np.arange(len(num_node_list)) - - seq_list = [] - for n, kind, radius, y in zip(num_node_list, kind_list, radius_list, y_list): - b = NodeBrush(kind, ax) - seq_list.append(node_sequence(b, n, center=(0, y))) - - eb = EdgeBrush('-->', ax) - for st, et in zip(seq_list[:-1], seq_list[1:]): - connecta2a(st, et, eb) - - -def real_bp(): - with DynamicShow((6, 6), '_feed_forward.png') as d: - draw_feed_forward(d.ax, num_node_list=list) - batch_sz = 10 layers = 1 @@ -72,6 +42,3 @@ end = time.time() wandb.run.summary["time"] = end-init wandb.save('jacobian.h5') - -with DynamicShow((6, 6), '_feed_forward.png') as d: - draw_feed_forward(d.ax, num_node_list=layers_list)