示例#1
0
      #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)