'structure': { 'input': 400, 'hidden': [25], 'output': 10, } } # initialize the neural network with full data set mpl = Perceptron(y, x, Options) print('Params: ' + str(len(mpl.params))) print(mpl.size) print('') print('Cost Function: ' + str(mpl.cost_function(mpl.params))) print('Accuracy : ' + str(mpl.accuracy(mpl.h, yl, 1))) print('') print('* Gradient Descent') mpl.gradient_descent(10) print('Accuracy : ' + str(mpl.accuracy(mpl.h, yl, 1))) print('') print('* LBFGS Optimization') mpl.lbfgs(150) print('Cost Function: ' + str(mpl.cost_function(mpl.params))) print('Accuracy : ' + str(mpl.accuracy(mpl.h, yl, 1))) print('')
#0 0.3155 99.87 23.8 48.38 11.42 for s in struct: Options["structure"]["hidden"] = s Options['regularization'] = 1.0 info = str() tp = Perceptron(train_set['y'], train_set['x'], Options) print('\nStructure: ' + str(s) + '\tparams: ' + str(len(tp.params))) print('idx cost acc acc norm time') print('-----------------------------------------') for i in range(0, test): mpl = Perceptron(train_set['y'], train_set['x'], Options) lb = lambda: mpl.lbfgs(ite_table[3]) time = tm.timeit(lb, number=1) h1 = mpl.predict(train_set['x'], mpl.params) h2 = mpl.predict(valid_set['x'], mpl.params) info = str(i) + '\t' + \ str(mpl.cost_function(mpl.params))[0:6] + '\t' +\ str(mpl.accuracy(h1, train_set['yl'], 1))[0:5] + '\t' +\ str(mpl.accuracy(h2, valid_set['yl'], 1))[0:5] + '\t' +\ str(np.linalg.norm(mpl.params))[0:5] + '\t' +\ str(time)[0:5] + str('') print(info)