def main(): start = datetime.now() print "Loading Data..." X_tr, y_tr, X_te, y_te = ml_utils.loaddata('./MiniBooNE_PID.txt') print X_tr.shape, y_tr.shape """
import hw_utils from datetime import datetime X_train, Y_train, X_test, Y_test = hw_utils.loaddata("MiniBooNE_PID.txt") X_train_norm, X_test_norm = hw_utils.normalize(X_train, X_test) # # Part d linear activations # print "Linear Activations" # linear_arch1 = [[50, 2],[50, 50, 2],[50, 50, 50, 2],[50, 50, 50, 50, 2]] # start = datetime.now() # hw_utils.testmodels(X_train_norm, Y_train, X_test_norm, Y_test, # linear_arch1, 'linear', 'softmax',[0.0], 30, 1000, 0.001, [0.0], [0.0], False, False, 1) # end = datetime.now() # print "Time taken in Linear activations part 1 : " + str((end - start).total_seconds()) # # linear_arch2 = [[50, 50, 2], [50, 500, 2], [50, 500, 300, 2], [50, 800, 500, 300, 2], [50, 800, 800, 500, 300, 2]] # start = datetime.now() # hw_utils.testmodels(X_train_norm, Y_train, X_test_norm, Y_test, # linear_arch2, 'linear', 'softmax',[0.0], 30, 1000, 0.001, [0.0], [0.0], False, False, 1) # end = datetime.now() # print "Time taken in Linear activations part 2 : " + str((end - start).total_seconds()) # # arch = [[50, 50, 2], [50, 500, 2], [50, 500, 300, 2], [50, 800, 500, 300, 2], [50, 800, 800, 500, 300, 2]] # # # Part e sigmoid activation # print "\n\nSigmoid activation" # start = datetime.now() # hw_utils.testmodels(X_train_norm, Y_train, X_test_norm, Y_test, # arch, 'sigmoid', 'softmax',[0.0], 30, 1000, 0.001, [0.0], [0.0], False, False, 1) # end = datetime.now() # print "Time taken in Sigmoid activation : " + str((end - start).total_seconds())
import hw_utils as hw from timeit import default_timer xTrain, yTrain, xTest, yTest = hw.loaddata('MiniBooNE_PID.txt') xTrainNorm, xTestNorm = hw.normalize(xTrain, xTest) dIn = 50 dOut = 2 xTrain = xTrainNorm yTrain = yTrain xTest = xTestNorm yTest = yTest print "\nLinear Activations" print "-------------------" print "Architecture 1" print "---------------" architectures = [[dIn, dOut], [dIn, 50, dOut], [dIn, 50, 50, dOut], [dIn, 50, 50, 50, dOut]] startTime = default_timer() hw.testmodels(xTrain, yTrain, xTest, yTest, architectures, 'linear', 'softmax', [0.0], 30, 1000, 0.001, [0.0], [0.0], False, False, 0) timeTaken = default_timer() - startTime print "Training time = " + str(timeTaken) + " s" print "Architecture 2" print "---------------" architectures = [[dIn, 50, dOut], [dIn, 500, dOut], [dIn, 500, 300, dOut], [dIn, 800, 500, 300, dOut], [dIn, 800, 800, 500, 300, dOut]] startTime = default_timer()
import time def start_time(): start_time = time.time() return start_time def end_time(start_time): print "--- %s seconds ---" % (time.time() - start_time) return time.time() - start_time print ' 3 (c) 1 Load Data' X_tr, y_tr, X_te, y_te = hw_utils.loaddata('MiniBooNE_PID.txt') print X_tr.shape, X_te.shape, y_tr.shape, y_te.shape print ' 3 (c) 2 Normalization' X_tr, X_te = hw_utils.normalize(X_tr, X_te) print X_tr.shape, X_te.shape din = 50 dout = 2 arch_list1 = [[din, dout], [din, 50, dout], [din, 50, 50, dout], [din, 50, 50, 50, dout]] print arch_list1 print ' 3 (h) Early Stopping and L2-regularization' time_g = start_time() arch_list_e = [[din, 800, 500, 300, dout]]
sgd_lr=0.00001, sgd_decays=decay_list, sgd_moms=[0.99], sgd_Nesterov=True, EStop=True, verbose=0) print " Time Taken = ", time.time() - start_time displayJson(results) if __name__ == "__main__": #Part A) Load and normalize start_time = time.time() X_tr, y_tr, X_te, y_te = hw.loaddata(FILENAME) print "Time taken to load data = ", time.time() - start_time start_time = time.time() X_tr, X_te = hw.normalize(X_tr, X_te) print "Time taken to normalize data = ", time.time() - start_time #Part D) #partd_a(X_tr,y_tr,X_te,y_te) #partd_b(X_tr,y_tr,X_te,y_te) #parte(X_tr,y_tr,X_te,y_te) #partf(X_tr,y_tr,X_te,y_te) #partg(X_tr,y_tr,X_te,y_te)