Ejemplo n.º 1
0
def fitness_func(ind, queue=None):
    assert not ind.fitness, "Recalculation of existing fitness value -> This shouldn't have happened!"

    data = CData("TestData/Dohany_ANN/full.csv", cross_val=.2, header=True, sep=";")
    repeats = ind.genome[1]
    ind.phenotype = get_brain(ind.genome, data)

    for _ in range(repeats):
        for batch in data.batchgen(5):
            ind.phenotype.learn(batch)

    fitness = data.test(ind.phenotype)
    ind.fitness = fitness

    # If parallelization is involved
    if queue:
        queue.put(ind)
Ejemplo n.º 2
0
import time

from AI.Architecture.FFNN import FFLayerBrain
from Wrappers.DataModel import CData

HIDDENS = (30,)
RATE = 3
REPEATS = 1
BATCHSIZE = 10

start = time.time()

myData = CData("TestData/MNIST/mnist.pkl.gz", cross_val=0.2, header=False)

INPUTS, OUTPUTS = myData.neurons_required()
LAYOUT = [INPUTS] + list(HIDDENS) + [OUTPUTS]

archimedes = FFLayerBrain(RATE, layout=LAYOUT)

for epoch in range(REPEATS):
    batches = myData.batchgen(BATCHSIZE)
    for index, batch in enumerate(batches):
        if index % 200 == 0:
            right = myData.test(archimedes, "testing")
            print(index * BATCHSIZE, right, sep="\t")
        archimedes.learn(batch)

    rrate = myData.test(archimedes)  # Right-rate
    print("Test @{}:".format(epoch), rrate, sep="\t")

print("Learning is done! Time required: {} seconds.".format(int(time.time() - start)))
Ejemplo n.º 3
0
    stop = time.time() - start
    print("Learning phase took {} seconds.".format(round(stop, 2)))
    print("Average speed per lesson: {} seconds.".format(round(stop, 2)))

    print("!!!!!!!!!!!!!!!!!!!! Testing Archon !!!!!!!!!!!!!!!!!!!!!!!!")
    print("Testing on <testing> data... ", sep="\t", end="")
    t = myData.test(archon, "learning")
    print("{}%".format(round(t, 4) * 100))
    print("Testing on <learning> data...", sep="\t", end="")
    l = myData.test(archon, "testing")
    print("{}%".format(round(t, 4) * 100))
    return t, l


myData = CData("TestData/Dohany_ANN/full.csv", cross_val=.20, header=True, sep=";")

INPUTS, OUTPUTS = myData.neurons_required()
LAYOUT = [INPUTS] + list(HIDDENS) + [OUTPUTS]

glob_start = time.time()

archon = None
result = 0
epoch = 1

while result < .99:
    print("\n------------------------------------------------------------")
    print("!!!!!!!!!!!!!!!!!!!!! {}. run started !!!!!!!!!!!!!!!!!!!!!!!"
          .format(epoch))
    print("------------------------------------------------------------")
Ejemplo n.º 4
0
from AI.Architecture.FFNN import *
from Wrappers.DataModel import CData

# ARCHITECTURE = FFNeuralBrain
ARCHITECTURE = FFLayerBrain

bob = ARCHITECTURE(1, (2, 3, 2))
bob.shuffle(1)
data = CData("TestData/LogicGates/AND.txt")
for i in range(10000):
    if i % 1000 == 0:
        print("Error @:", i, data.test(bob, "l"), sep="\t")
    bob.learn(data.table())