Beispiel #1
0
Created on Mon Aug 31 13:36:03 2015

@author: tmold_000
"""
from pybrain.datasets import SupervisedDataSet
import numpy as np
import math
import dataParser
import Normalizers

numInputs = 31
numOutputs = 28

#generations, generationsToInputs, generationsToOutputs = dataParser.parse(fname = "whole_population_0.txt")

trainingInputs, trainingOutputs, testInputs, testOutputs = dataParser.makeSets(X = generationsToInputs, Y = generationsToOutputs, generations = generations[130:200], examplesPerGeneration = 500, testProportion = 0.25)
#
#X = Normalizers.gaussNormalize(trainingInputs)
#Xtest = Normalizers.gaussNormalize(testInputs)
#
#Y = Normalizers.gaussNormalize(trainingOutputs)
#Ytest = Normalizers.gaussNormalize(testOutputs)

X = trainingInputs
Xtest = testInputs
Y = trainingOutputs
Ytest = testOutputs

trainingSet = SupervisedDataSet(numInputs, numOutputs)
for x, y in zip(X, Y):
    trainingSet.appendLinked(x, y)
Beispiel #2
0
        max_epochs=1500,  # we want to train this many epochs
        verbose=1,
        )
    #if (loadFile != ""):
        #net1.load_params_from(loadFile)
    net1.max_epochs = 50
    net1.update_learning_rate = ln;

    return net1


    
generations, generationsToInputs, generationsToOutputs = dataParser.parse(fname = "whole_population_0.txt")
iters = 150
saveFile = "LasagneWeights400_2Layer"
trainingInputs, trainingOutputs, testInputs, testOutputs = dataParser.makeSets(generationsToInputs, generationsToOutputs, generations[0:200], 1, 0.25)
ln = 0.01
X = Normalizers.gaussNormalize(trainingInputs)
Xtest = Normalizers.gaussNormalize(testInputs)
#
Y = Normalizers.gaussNormalize(trainingOutputs)
Ytest = Normalizers.gaussNormalize(testOutputs)

X = np.asarray(X, np.float32)
Y = np.asarray(Y, np.float32)
Xtest= np.asarray(Xtest, np.float32)
Ytest = np.asarray(Ytest, np.float32)
net = createNet(X, Y, ln, saveFile)
for n in range(iters): 
    net.fit(X, Y) # This thing try to do the fit itself
    y_pred = net.predict(Xtest)