コード例 #1
0
def demo():

    parser = argparse.ArgumentParser()
    parser.add_argument('-f',
                        action='store',
                        required=True,
                        dest='trainfile',
                        help='file for train')
    parser.add_argument('-w',
                        action='store',
                        required=True,
                        dest='weightfile',
                        help='weight file for train')
    inputs = parser.parse_args()
    writeTrainWeights(inputs.weightfile)
    pointNum, pat = readfile(learnParameters.expandfeature(inputs.trainfile))
    print pat
    print('file read over ,the train has began please wait for a momment')
    n = NN(pointNum, pointNum, 1)
    #for i in xrange(100):
    f_wfile = open(inputs.weightfile, 'r')
    for line in f_wfile:
        line = line.strip('\n')
        line = line.split(':')
        iterations = int(line[0])
        N_value = float(line[1])
        M_value = float(line[2])
        print('iterations=%d,N=%f,M=%f' % (iterations, N_value, M_value))
        n.train(pat, iterations, N_value, M_value)
        n.weights()
        print('Next paratermeters........')
    f_wfile.close()
コード例 #2
0
def demo():
   
    parser=argparse.ArgumentParser()
    parser.add_argument('-f', action='store', required=True, dest='trainfile',
                    help='file for train')
    parser.add_argument('-w', action='store', required=True, dest='weightfile',
                    help='weight file for train')
    inputs=parser.parse_args()
    writeTrainWeights(inputs.weightfile)
    pointNum,pat=readfile(learnParameters.expandfeature(inputs.trainfile))
    print pat
    print('file read over ,the train has began please wait for a momment')
    n=NN(pointNum,pointNum,1)
    #for i in xrange(100):
    f_wfile=open(inputs.weightfile,'r')
    for line in f_wfile:
        line=line.strip('\n')
        line=line.split(':')
        iterations=int(line[0])
        N_value=float(line[1])
        M_value=float(line[2])
        print('iterations=%d,N=%f,M=%f'%(iterations,N_value,M_value))
        n.train(pat,iterations,N_value,M_value)
        n.weights()
        print('Next paratermeters........')
    f_wfile.close()
コード例 #3
0
def psolearn(trainfile, N_value, M_value):
    pointNum, pat = readfile(learnParameters.expandfeature(trainfile))
    print('file read over ,the train has began please wait for a momment')
    n = NN(pointNum, pointNum, 1)
    #for i in xrange(100):
    iterations = 1000
    value = n.train(pat, iterations, N_value, M_value)
    print('N_value:%f,M_value:%f' % (N_value, M_value))
    #n.weights()
    return value
コード例 #4
0
def psolearn(trainfile,N_value,M_value):
    pointNum,pat=readfile(learnParameters.expandfeature(trainfile))
    print('file read over ,the train has began please wait for a momment')
    n=NN(pointNum,pointNum,1)
    #for i in xrange(100):
    iterations=1000
    value=n.train(pat,iterations,N_value,M_value)
    print ('N_value:%f,M_value:%f'%(N_value,M_value))
    #n.weights()
    return value