示例#1
0
def pairPop (pop, verbose=True):
    """Takes a population of NNs and calculates the error and returns a
    list containing the weights of each individual with its associated 
    errors and fitnesses"""
    weights, errors = [], []
    for i in range(len(pop)):                 
        weights.append([pop[i].wi.copy(), pop[i].wo.copy()])
        errors.append(pop[i].sumErrors())       
    fitnesses = calcFit(errors)
    if verbose:
        for i in range(int(NN.pop_size * 0.15)): 
            print str(i).zfill(2), '1/sum(MSEs)', str(errors[i]).rjust(15), \
                str(int(errors[i] * NN.graphical_error_scale) * '-').rjust(20), \
                'fitness'.rjust(12), str(fitnesses[i]).rjust(17), \
                str(int(fitnesses[i] * 1000) * '-').rjust(20)
    return zip(weights, errors, fitnesses)
示例#2
0
def pairPop(pop, verbose=True):
    """Takes a population of NNs and calculates the error and returns a
    list containing the weights of each individual with its associated 
    errors and fitnesses"""
    weights, errors = [], []
    for i in range(len(pop)):
        weights.append([deepcopy(pop[i].wi), deepcopy(pop[i].wo)])
        errors.append(pop[i].sumErrors())
    fitnesses = calcFit(errors)
    if verbose:
        for i in range(int(NN.pop_size * 0.15)):
            print str(i).zfill(2), '1/sum(MSEs)', str(errors[i]).rjust(15), \
                str(int(errors[i] * NN.graphical_error_scale) * '-').rjust(20), \
                'fitness'.rjust(12), str(fitnesses[i]).rjust(17), \
                str(int(fitnesses[i] * 1000) * '-').rjust(20)
    return zip(weights, errors, fitnesses)
示例#3
0
def pairPop(pop, verbose=NN.eliteN):
    """Takes a population of NNs and calculates the error and returns a
    list containing the weights of each individual with its associated 
    errors and fitnesses"""
    weights, inv_errs, perc_accs = [], [], []
    for i in range(len(pop)):
        weights.append([pop[i].wi.copy(), pop[i].wo.copy()])
        inv_err, perc_acc = pop[i].sumErrors()
        inv_errs.append(inv_err)
        perc_accs.append(perc_acc)
    fitnesses = calcFit(perc_accs)
    if verbose:
        for i in range(verbose):
            print str(i).zfill(2), 'perc acc', str(perc_accs[i]).rjust(15), \
                str(int(perc_accs[i] * NN.graphical_error_scale) * '-').rjust(20), \
                'fitness'.rjust(12), str(fitnesses[i]).rjust(17), \
                str(int(fitnesses[i] * 1000) * '-').rjust(20)
        print 'lowest fittness', min(fitnesses)
    return zip(weights, inv_errs, perc_accs, fitnesses)
示例#4
0
def pairPop(pop, verbose=NN.eliteN):
    """Takes a population of NNs and calculates the error and returns a
    list containing the weights of each individual with its associated 
    errors and fitnesses"""
    weights, inv_errs, perc_accs = [], [], []
    for i in range(len(pop)):    
        weights.append([pop[i].wi.copy(), pop[i].wo.copy()])
        inv_err, perc_acc = pop[i].sumErrors()
        inv_errs.append(inv_err)
        perc_accs.append(perc_acc)
    fitnesses = calcFit(perc_accs)
    if verbose:
        for i in range(verbose): 
            print str(i).zfill(2), 'perc acc', str(perc_accs[i]).rjust(15), \
                str(int(perc_accs[i] * NN.graphical_error_scale) * '-').rjust(20), \
                'fitness'.rjust(12), str(fitnesses[i]).rjust(17), \
                str(int(fitnesses[i] * 1000) * '-').rjust(20)
        print 'lowest fittness', min(fitnesses)
    return zip(weights, inv_errs, perc_accs, fitnesses)