commit 4b5cbf01fd46f774ee23aadbb334d47514a45e2e
parent 9bf64326838a903dcc1cf9390fc7e056bf99a1c2
Author: David Freifeld <freifeld.david@gmail.com>
Date: Mon, 29 Mar 2021 11:43:43 -0700
Remove old scripts/benchmarks
Diffstat:
7 files changed, 0 insertions(+), 361 deletions(-)
diff --git a/bench/benchmark.py b/bench/benchmark.py
@@ -1,91 +0,0 @@
-#
-# benchmark.py
-# Jacobian
-#
-# Created by David Freifeld
-# Copyright © 2020 David Freifeld. All rights reserved.
-#
-
-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, 0.9)
- net.add_layer(4, "linear")
- for i in range(layers):
- net.add_layer(5, "relu")
- net.add_layer(2, "linear")
- net.initialize()
- initend = time.time()
- for i in range(50):
- net.train()
- end = time.time()
- return (end-init)
-
-for i in range(1):
- print(bench(16,1))
-
-# x = []
-# y = []
-# i = 1
-# while(i < 125):
-# print(i)
-# y.append(bench(i, 1))
-# x.append(i)
-# i+=1;
-# plt.plot(x,y, label = "Jacobian (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()
-# print(y)
-
-fig, axs = plt.subplots(2, 2)
-axs[0,0].plot([0.5025448077098257, 0.06346596189658764, 0.047917547554598754, 0.04105092616154024, 0.03523913263298199, 0.031739621835796136, 0.028315013611574093, 0.026019472083075448, 0.024406521083899426, 0.022933075354279908, 0.021600019709607246, 0.020935506796379722, 0.020341872339561994, 0.019887265494774282, 0.019298826768017932, 0.019021222173712722, 0.018694215646250782, 0.01869210122639975, 0.01835323961580634, 0.01805996506773795, 0.017826852610588563, 0.017619089276841214, 0.0173522467286016, 0.017464391304677935, 0.01741090491941103, 0.016986178006763254, 0.016966580251704732, 0.016847677484476468, 0.01688444716072269, 0.016816666155598632, 0.016728257525321137, 0.01650929572067639, 0.016523535019764574, 0.016360246686629634, 0.016583477585886453, 0.016515186448995516, 0.016167543447082024, 0.016142403505456843, 0.016143194300608676, 0.01618973151673178, 0.01584432253715314, 0.01614457198639892, 0.015996006825746038, 0.015867076906405406, 0.015746370663870562, 0.015635421002396035, 0.015604364669764566, 0.01580412467568558, 0.015422517508656697, 0.01570749596837556], label="Keras", color="r")
-axs[0,0].plot([0.7879068318088323, 0.09516164867688488, 0.07563164060478968, 0.06368552646692226, 0.054840093046821504, 0.04791283077060782, 0.04277797107467588, 0.03926807701809714, 0.03580813260983355, 0.03316434786118419, 0.03137411057504992, 0.029850296676158905, 0.028874377368499113, 0.02738272940234238, 0.026146136594331817, 0.025704378878932125, 0.02479495369638039, 0.02364667130646524, 0.023422482195279457, 0.02243726485908426, 0.021918368050890254, 0.021494656505174195, 0.021088606653278632, 0.020731150474868072, 0.020081241636703544, 0.01991242998347476, 0.019817821484133108, 0.01929077183186317, 0.019043239484238902, 0.01861191921503536, 0.01828094854309464, 0.017715507970247048, 0.01763268999311308, 0.017503339562885807, 0.017498996990751352, 0.016864338578249247, 0.016716289371005354, 0.01664047861866505, 0.016465328815732372, 0.016277130278419483, 0.016030110511312028, 0.015790291867582806, 0.015560780664202788, 0.015480223164233742, 0.015054066943017063, 0.015169570015879064, 0.014821364322294858, 0.014672116970100643, 0.01468882526869312, 0.014406936027306989], label="Keras (w/ val split)")
-axs[0,0].plot([0.6356955872469517, 0.4474506605850878, 0.3890421118235231, 0.3383762977820027, 0.2570263108725408, 0.17083878727236804, 0.1206560030408328, 0.09028454783518607, 0.06834034661147965, 0.05482004367813022, 0.046493575456135125, 0.04067401763115656, 0.03674237276445186, 0.03355837383721336, 0.03091509716139769, 0.028653709084133477, 0.026661936578240484, 0.024985219962964603, 0.023432621666806992, 0.022137642019742405, 0.020931669067147784, 0.019861774528818207, 0.018922685342936688, 0.018049194997636995, 0.017238716312126513, 0.016458408508859233, 0.0158025484137779, 0.015156084850422274, 0.014549496406066243, 0.014012374438633365, 0.013499269858957372, 0.013027227670698194, 0.01258420495404383, 0.012184903993599385, 0.011772133709941639, 0.01141798619621345, 0.011055273510342334, 0.01075009333315004, 0.010450198537204518, 0.010153955363072054, 0.009865946080363197, 0.009610634188130004, 0.009366072731556546, 0.009125463513132877, 0.008900918802492984, 0.008680248000794285, 0.008473303210025152, 0.008258737640210677, 0.008091226337141558, 0.007901268149935282], label = "SciKit Learn", color='orange')
-axs[0,0].plot([0.147248, 0.0459116, 0.0426555, 0.0399301, 0.038506, 0.0373933, 0.0364922, 0.0356698, 0.0350383, 0.0344831, 0.0340619, 0.0336462, 0.0332532, 0.0329713, 0.032643, 0.0323429, 0.0320908, 0.0318416, 0.0316404, 0.0315699, 0.0313803, 0.0311661, 0.0310349, 0.030904, 0.030829, 0.0307032, 0.0306185, 0.0305414, 0.0305478, 0.0304674, 0.0304535, 0.0303114, 0.0303842, 0.0302684, 0.0302227, 0.0301911, 0.0301535, 0.0301598, 0.0300992, 0.0301056, 0.0300929, 0.0301216, 0.0299648, 0.0300934, 0.0299637, 0.030046, 0.0299663, 0.0299561, 0.0299137, 0.0298976], label = "Jacobian", color="g")
-
-# axs[0,1].plot([0.6614238410596026, 0.8857615894039735, 0.9461920529801324, 0.9718543046357616, 0.9834437086092715, 0.9867549668874173, 0.9950331125827815, 0.9942052980132451, 0.9950331125827815, 0.9966887417218543, 0.9975165562913907, 0.9975165562913907, 0.9983443708609272, 0.9983443708609272, 0.9991721854304636, 0.9983443708609272, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 1.0, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 1.0, 0.9991721854304636, 1.0, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 1.0, 0.9991721854304636, 1.0, 0.9991721854304636, 0.9991721854304636, 0.9975165562913907, 0.9991721854304636, 0.9966887417218543, 0.9991721854304636], label="Keras", color="r")
-axs[0,1].plot([0.7425496688741722, 0.9130794701986755, 0.918046357615894, 0.9619205298013245, 0.9693708609271523, 0.9701986754966887, 0.9668874172185431, 0.9685430463576159, 0.9627483443708609, 0.9735099337748344, 0.9693708609271523, 0.9710264900662252, 0.9677152317880795, 0.9644039735099338, 0.9751655629139073, 0.9759933774834437, 0.9718543046357616, 0.9685430463576159, 0.9677152317880795, 0.9677152317880795, 0.9735099337748344, 0.9718543046357616, 0.9768211920529801, 0.972682119205298, 0.9735099337748344, 0.9743377483443708, 0.9718543046357616, 0.9751655629139073, 0.9759933774834437, 0.9710264900662252, 0.9743377483443708, 0.9759933774834437, 0.9743377483443708, 0.9759933774834437, 0.9751655629139073, 0.9735099337748344, 0.972682119205298, 0.9751655629139073, 0.9743377483443708, 0.9718543046357616, 0.9768211920529801, 0.9793046357615894, 0.9817880794701986, 0.9776490066225165, 0.9776490066225165, 0.9776490066225165, 0.9776490066225165, 0.9751655629139073, 0.9751655629139073, 0.9759933774834437], label="Keras", color="r")
-axs[0,1].plot([0.6614238410596026, 0.8857615894039735, 0.9461920529801324, 0.9718543046357616, 0.9834437086092715, 0.9867549668874173, 0.9950331125827815, 0.9942052980132451, 0.9950331125827815, 0.9966887417218543, 0.9975165562913907, 0.9975165562913907, 0.9983443708609272, 0.9983443708609272, 0.9991721854304636, 0.9983443708609272, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 1.0, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 1.0, 0.9991721854304636, 1.0, 0.9991721854304636, 0.9991721854304636, 0.9991721854304636, 1.0, 0.9991721854304636, 1.0, 0.9991721854304636, 0.9991721854304636, 0.9975165562913907, 0.9991721854304636, 0.9966887417218543, 0.9991721854304636], label="Keras (w/ val split)")
-axs[0,1].plot([0.7014147431124349, 0.7967237527922562, 0.9009679821295606, 0.9635145197319435, 0.9746835443037974, 0.9806403574087863, 0.9888309754281459, 0.9851079672375279, 0.992553983618764, 0.9932985852568875, 0.9955323901712584, 0.996276991809382, 0.9970215934475056, 0.9970215934475056, 0.9970215934475056, 0.9970215934475056, 0.9977661950856291, 0.9977661950856291, 0.9985107967237528, 0.9985107967237528, 0.9985107967237528, 0.9985107967237528, 0.9985107967237528, 0.9985107967237528, 0.9985107967237528, 0.9985107967237528, 0.9985107967237528, 0.9985107967237528, 0.9992553983618764, 0.9992553983618764, 0.9992553983618764, 0.9992553983618764, 0.9992553983618764, 0.9992553983618764, 0.9992553983618764, 0.9992553983618764, 0.9992553983618764, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], label="SciKit Learn", color="orange")
-axs[0,1].plot([0.942975, 0.980992, 0.983471, 0.98595, 0.98595, 0.985124, 0.98595, 0.984298, 0.985124, 0.985124, 0.985124, 0.98595, 0.98595, 0.98595, 0.986777, 0.98595, 0.98595, 0.98595, 0.98595, 0.98595, 0.986777, 0.986777, 0.986777, 0.98595, 0.986777, 0.986777, 0.986777, 0.98595, 0.98595, 0.98595, 0.986777, 0.98595, 0.986777, 0.98595, 0.98595, 0.98595, 0.98595, 0.98595, 0.98595, 0.98595, 0.98595, 0.985124, 0.98595, 0.984298, 0.985124, 0.98595, 0.984298, 0.985124, 0.984298, 0.984298], label="Jacobian", color="g")
-
-axs[1,0].plot([0.10888315538565317, 0.06680880729798917, 0.053077199889553915, 0.07688223214613067, 0.045733443758002035, 0.03640310698085361, 0.031724032787261186, 0.04391241666895372, 0.031088130314041066, 0.026419770469268165, 0.026483222897405977, 0.02286748499781997, 0.023777789181029355, 0.01819943821540585, 0.021010621030021596, 0.017266716283780556, 0.015340352886252934, 0.016395327476439653, 0.01578087834296403, 0.015752164343440973, 0.01598852108474131, 0.01501362330659672, 0.016887195642899585, 0.016618405779202778, 0.011775514552438702, 0.013678248254237352, 0.011577272056429475, 0.011427491268625967, 0.014759536873963143, 0.011453486385720748, 0.013112282615017007, 0.012316111875353036, 0.017063750271443967, 0.010874567663779965, 0.011459515726676694, 0.011196554424586119, 0.010264440970840278, 0.011569284523526827, 0.009628297457540477, 0.009635593286818928, 0.01166622194427031, 0.016940338909626006, 0.014556518707562376, 0.01091362305537418, 0.019304899429833447, 0.014454653472812088, 0.018006062010924022, 0.018680620772971047, 0.014109227254434867, 0.011193500597167899], label="Keras (w/ val split)")
-axs[1,0].plot([0.0234097, 0.0141612, 0.0114124, 0.00986921, 0.00872293, 0.00805279, 0.00776756, 0.00758032, 0.00742217, 0.00729374, 0.0071354, 0.00701655, 0.0068978, 0.00680974, 0.00674059, 0.00668204, 0.00665047, 0.00661398, 0.00658959, 0.00655535, 0.00652, 0.00649501, 0.00647428, 0.00644689, 0.00643667, 0.00639617, 0.00637101, 0.00636733, 0.00634465, 0.00632476, 0.00632126, 0.00630413, 0.00628944, 0.00627891, 0.00626959, 0.0062554, 0.00623879, 0.00623331, 0.00622584, 0.00621284, 0.00620501, 0.00619419, 0.00618274, 0.00617308, 0.00616499, 0.00615112, 0.00612101, 0.00609225, 0.00607023, 0.0060534], label="Jacobian", color="g")
-
-axs[1,1].plot([0.8518518527348836, 0.9481481481481482, 1.0, 0.9481481481481482, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], label="Keras (w/ val split)")
-axs[1,1].plot([0.6888888888888889, 0.837037037037037, 0.9259259259259259, 0.9407407407407408, 0.9777777777777777, 0.9777777777777777, 0.9777777777777777, 0.9777777777777777, 0.9851851851851852, 0.9851851851851852, 0.9851851851851852, 0.9851851851851852, 0.9851851851851852, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] + ([1.0] * 25), label="SciKit Learn", color="orange")
-axs[1,1].plot([0.954887, 0.954887, 0.954887, 0.954887, 0.954887, 0.954887, 0.954887, 0.954887, 0.954887, 0.954887, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406, 0.962406], label="Jacobian", color="g")
-
-axs[0,0].legend(loc="upper right")
-axs[0,1].legend(loc="lower right")
-axs[1,0].legend(loc="upper right")
-axs[1,1].legend(loc="lower right")
-axs[0,0].set_xlabel("Epoch")
-axs[0,0].set_ylabel("Loss")
-axs[0,1].set_xlabel("Epoch")
-axs[0,1].set_ylabel("Accuracy")
-axs[1,0].set_xlabel("Epoch")
-axs[1,0].set_ylabel("Validation loss")
-axs[1,1].set_xlabel("Epoch")
-axs[1,1].set_ylabel("Validation accuracy")
-fig.suptitle("Model metrics over epochs", fontsize=16)
-plt.show()
-
-# x = ['Keras', 'Scikit-Learn', 'Jacobian (Python)', 'Jacobian (C++)']
-# speed = [2.87004685402, 2.074756145477295,0.05295228958129883, 0.0521543]
-
-# x_pos = [i for i, _ in enumerate(x)]
-
-# plt.bar(x_pos, speed, color='green')
-# plt.ylabel("Time (s)")
-# plt.title("Runtime for Task")
-
-# plt.xticks(x_pos, x)
-
-plt.show()
diff --git a/bench/kerasdemo.py b/bench/kerasdemo.py
@@ -1,48 +0,0 @@
-#
-# kerasdemo.py
-# Jacobian
-#
-# Created by David Freifeld
-#
-#+-----------------------------------------------------------------------------+
-# Keras benchmark code to compare with network.
-#
-# Runs a fully connected feedforward neural network with backpropagation for 50
-# epochs, then tests on data. First layer has 4 neurons, 2 hidden layers have 5,
-# output layer has 1. All four layers use sigmoid for activation.
-#
-# Taken and loosely modified from:
-# https://machinelearningmastery.com/tutorial-first-neural-network-python-keras/
-#+-----------------------------------------------------------------------------+
-
-import time
-import numpy
-# import tensorflow
-from numpy import loadtxt
-import keras
-from keras import backend as K
-from keras.models import Sequential
-from keras.layers import Activation
-from keras.layers import Dense
-
-def kerasbench(batch_sz, layers, epochs):
- init = time.time()
- dataset = loadtxt('data_banknote_authentication.txt', delimiter=',')
- X = dataset[:,0:4]
- y = dataset[:,4]
- model = Sequential()
- model.add(Dense(4, input_dim=4, activation='linear'))
- for i in range(layers):
- model.add(Dense(5, activation='sigmoid'))
- model.add(Dense(1, activation='linear'))
- opt = keras.optimizers.SGD(lr=0.0155)
- model.compile(loss='mse', optimizer=opt, metrics=['accuracy'])
- history = model.fit(X, y, epochs=epochs, validation_split=0.1, batch_size=batch_sz)
- end = time.time()
- print(history.history['loss'])
- print(history.history['acc'])
- print(history.history['val_loss'])
- print(history.history['val_acc'])
- return (end-init)
-
-print(kerasbench(10,1,50))
diff --git a/bench/mlpack.cpp b/bench/mlpack.cpp
@@ -1,56 +0,0 @@
-#include <mlpack/core.hpp>
-#include <mlpack/methods/ann/layer/layer.hpp>
-#include <mlpack/methods/ann/ffn.hpp>
-using namespace mlpack;
-using namespace mlpack::ann;
-int main()
-{
- // Load the training set and testing set.
- arma::mat trainData;
- data::Load("data_banknote_authentication.csv", trainData, true);
- arma::mat testData;
- data::Load("test.csv", testData, true);
- // Split the labels from the training set and testing set respectively.
- arma::mat trainLabels = trainData.row(trainData.n_rows - 1);
- arma::mat testLabels = testData.row(testData.n_rows - 1);
- trainData.shed_row(trainData.n_rows - 1);
- testData.shed_row(testData.n_rows - 1);
- // Initialize the network.
- FFN<> model;
- model.Add<Linear<> >(trainData.n_rows, 8);
- model.Add<SigmoidLayer<> >();
- model.Add<Linear<> >(8, 3);
- model.Add<LogSoftMax<> >();
- // Train the model.
- model.Train(trainData, trainLabels);
- // Use the Predict method to get the predictions.
- arma::mat predictionTemp;
- model.Predict(testData, predictionTemp);
- /*
- Since the predictionsTemp is of dimensions (3 x number_of_data_points)
- with continuous values, we first need to reduce it to a dimension of
- (1 x number_of_data_points) with scalar values, to be able to compare with
- testLabels.
- The first step towards doing this is to create a matrix of zeros with the
- desired dimensions (1 x number_of_data_points).
- In predictionsTemp, the 3 dimensions for each data point correspond to the
- probabilities of belonging to the three possible classes.
- */
- arma::mat prediction = arma::zeros<arma::mat>(1, predictionTemp.n_cols);
- // Find index of max prediction for each data point and store in "prediction"
- for (size_t i = 0; i < predictionTemp.n_cols; ++i)
- {
- // we add 1 to the max index, so that it matches the actual test labels.
- prediction(i) = arma::as_scalar(arma::find(
- arma::max(predictionTemp.col(i)) == predictionTemp.col(i), 1)) + 1;
- }
- /*
- Compute the error between predictions and testLabels,
- now that we have the desired predictions.
- */
- size_t correct = arma::accu(prediction == testLabels);
- double classificationError = 1 - double(correct) / testData.n_cols;
- // Print out the classification error for the testing dataset.
- std::cout << "Classification Error for the Test set: " << classificationError << std::endl;
- return 0;
-}
diff --git a/bench/pytorch.py b/bench/pytorch.py
@@ -1,48 +0,0 @@
-# -*- coding: utf-8 -*-
-import torch
-
-# N is batch size; D_in is input dimension;
-# H is hidden dimension; D_out is output dimension.
-N, D_in, H, D_out = 16, 1000, 6, 10
-
-# Create random Tensors to hold inputs and outputs
-x = torch.randn(N, D_in)
-y = torch.randn(N, D_out)
-
-# Use the nn package to define our model and loss function.
-model = torch.nn.Sequential(
- torch.nn.Linear(D_in, H),
- torch.nn.ReLU(),
- torch.nn.Linear(H, D_out),
-)
-loss_fn = torch.nn.MSELoss(reduction='sum')
-
-# Use the optim package to define an Optimizer that will update the weights of
-# the model for us. Here we will use Adam; the optim package contains many other
-# optimization algorithms. The first argument to the Adam constructor tells the
-# optimizer which Tensors it should update.
-learning_rate = 1e-4
-optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate)
-for t in range(500):
- # Forward pass: compute predicted y by passing x to the model.
- y_pred = model(x)
-
- # Compute and print loss.
- loss = loss_fn(y_pred, y)
- if t % 100 == 99:
- print(t, loss.item())
-
- # Before the backward pass, use the optimizer object to zero all of the
- # gradients for the variables it will update (which are the learnable
- # weights of the model). This is because by default, gradients are
- # accumulated in buffers( i.e, not overwritten) whenever .backward()
- # is called. Checkout docs of torch.autograd.backward for more details.
- optimizer.zero_grad()
-
- # Backward pass: compute gradient of the loss with respect to model
- # parameters
- loss.backward()
-
- # Calling the step function on an Optimizer makes an update to its
- # parameters
- optimizer.step()
diff --git a/bench/scikit.py b/bench/scikit.py
@@ -1,35 +0,0 @@
-from sklearn.neural_network import MLPClassifier
-import csv
-import matplotlib.pyplot as plt
-import time
-import numpy as np
-
-def bench(batch_sz, layers, layer_size, epochs, lr):
- start = time.time()
- with open("./data_banknote_authentication.txt", 'rt') as f:
- reader = csv.reader(f)
- data = list(reader)
- for a in data:
- for b, c in enumerate(a):
- a[b] = float(a[b])
-
- X_train = []
- y_train = []
- for i in data:
- X_train.append(i[:-1])
- y_train.append(i[-1])
-
- clf = MLPClassifier(solver="sgd", momentum=0, learning_rate_init=lr, batch_size=batch_sz, max_iter=1, hidden_layer_sizes=(layer_size), warm_start=True)
- accuracy = []1p
- for i in range(50):
- clf.fit(X_train, y_train)
- #accuracy.append(clf.score(X_train,y_train))
-
- end = time.time()
- #print(clf.loss_curve_)
- #print(clf.validation_scores_)
- #print(accuracy)
- #print(len(clf.loss_curve_), len(accuracy))
- return end-start
-
-print(bench(16))
diff --git a/scripts/example.py b/scripts/example.py
@@ -1,39 +0,0 @@
-import importlib.util
-spec = importlib.util.spec_from_file_location("mrbpnn", "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mrbpnn/mrbpnn.cpython-37m-darwin.so")
-mrbpnn = importlib.util.module_from_spec(spec)
-spec.loader.exec_module(mrbpnn)
-import numpy as np
-import matplotlib.pyplot as plt
-import numpy
-import time
-import wandb
-
-data_split = 0.9
-
-hyperparameter_defaults = dict(batch_size = 16,
- hidden_layers = 1,
- epochs = 50,
- learning_rate = 0.05,
- bias_lr = 0.03,
- activation = "lecun_tanh",
- neurons = 6,
- l = 0)
-
-wandb.init(project="jacobian", config=hyperparameter_defaults)
-config = wandb.config
-
-init = time.time()
-net = mrbpnn.Network("../data_banknote_authentication.txt", config.batch_size, config.learning_rate, config.bias_lr, config.l, data_split)
-net.add_layer(4, "linear")
-for i in range(config.hidden_layers):
- net.add_layer(config.neurons, config.activation)
-net.add_layer(2, "resig")
-net.initialize()
-
-for i in range(config.epochs):
- net.train()
- wandb.log({'accuracy': net.get_acc(), 'cost': net.get_cost(), 'val_accuracy': net.get_val_acc(), 'val_cost': net.get_val_cost()})
-end = time.time()
-
-wandb.run.summary["time"] = end-init
-wandb.save('jacobian.h5')
diff --git a/scripts/sweep.yaml b/scripts/sweep.yaml
@@ -1,44 +0,0 @@
-program: example.py
-method: bayes
-metric:
- name: val_accuracy
- goal: maximize
-parameters:
- epochs:
- distribution: int_uniform
- min: 25
- max: 100
- batch_size:
- distribution: int_uniform
- min: 5
- max: 200
- hidden_layers:
- distribution: int_uniform
- min: 1
- max: 6
- bias_lr:
- distribution: uniform
- min: 0.0001
- max: 0.5
- neurons:
- distribution: int_uniform
- min: 2
- max: 40
- activation:
- distribution: categorical
- values:
- - lecun_tanh
- - relu
- - sigmoid
- - linear
- - softplus
- - resig
- - cloglog
- learning_rate:
- distribution: uniform
- min: 0.0001
- max: 1
- l:
- distribution: uniform
- min: 0.001
- max: 5