示例#1
0
import matplotlib.pyplot as plt
import numpy as np

from dataSetTool import DataSetTool
from neuralNetwork.feedForwardNeuralNetwork import NeuralNetwork
from neuralNetwork.structure.layer import Layer
from numberGenerator.bounds import Bounds

np.set_printoptions(suppress=True)

dataSetTool = DataSetTool()
training, generalization, testing = dataSetTool.getIrisDataSets(
    '../../dataSet/iris/iris.data')

plt.grid(1)
plt.xlabel('Iterations')
plt.ylabel('Error')
plt.ylim([0, 1])
plt.ion()

l_rate = 0.5

bounds = Bounds(-2, 2)

inputLayer = Layer(bounds,
                   size=len(training[0][0]),
                   prev=None,
                   l_rate=l_rate,
                   bias=True,
                   label="Input layer")
hiddenLayer = Layer(bounds,
示例#2
0
import matplotlib.pyplot as plt
import numpy as np

from dataSetTool import DataSetTool
from neuralNetwork.feedForwardNeuralNetwork import NeuralNetwork
from neuralNetwork.structure.layer import Layer
from numberGenerator.bounds import Bounds

np.set_printoptions(suppress=True)

dataSetTool = DataSetTool()
training, testing, generalization = dataSetTool.getGlassDataSets(
    '../../dataSet/glass/glass.data')

l_rate = 0.01

bounds = Bounds(-2, 2)

inputLayer = Layer(bounds,
                   size=len(training[0][0]),
                   prev=None,
                   l_rate=l_rate,
                   bias=True,
                   label="Input layer")
hiddenLayer = Layer(bounds,
                    size=12,
                    prev=inputLayer,
                    l_rate=l_rate,
                    bias=True,
                    label="Hidden layer")
outputLayer = Layer(bounds,
示例#3
0
import matplotlib.pyplot as plt
import numpy as np

from dataSetTool import DataSetTool
from neuralNetwork.feedForwardNeuralNetwork import NeuralNetwork
from neuralNetwork.structure.layer import Layer
from numberGenerator.bounds import Bounds

np.set_printoptions(suppress=True)

dataSetTool = DataSetTool()
training, generalization, testing = dataSetTool.getHeartDataSets(
    '../../dataSet/heart/processed.cleveland.data')

plt.xlabel('Iterations')
plt.ylabel('Error')
plt.ion()

l_rate = 0.1

bounds = Bounds(-2, 2)

inputLayer = Layer(bounds,
                   size=len(training[0][0]),
                   prev=None,
                   l_rate=l_rate,
                   bias=True,
                   label="Input layer")
hiddenLayer = Layer(bounds,
                    size=6,
                    prev=inputLayer,
input = np.array([[0, 0],
                  [1, 0],
                  [0, 1],
                  [1, 1]])

target = np.array([[0],
                   [1],
                   [1],
                   [0]])

training = []
for x, y in zip(input, target):
    training.append((x, y))

# Get data set
dataSetTool = DataSetTool()
psonn.training, psonn.testing = training, training

psonn.bounds = Bounds(-5, 5)

# Create neural network
l_rate = None
inputLayer = Layer(psonn.bounds, size = 2, prev = None, l_rate = l_rate, bias = True, label = "Input layer")
hiddenLayer = Layer(psonn.bounds, size = 4, prev = inputLayer, l_rate = l_rate, bias = True, label = "Hidden layer")
outputLayer = Layer(psonn.bounds, size = 1, prev = hiddenLayer, l_rate = l_rate, bias = False, label = "Output layer")
psonn.nn = NeuralNetwork()
psonn.nn.appendLayer(inputLayer)
psonn.nn.appendLayer(hiddenLayer)
psonn.nn.appendLayer(outputLayer)

# Create the pso with the nn weights
示例#5
0
import matplotlib.pyplot as plt
import numpy as np

from dataSetTool import DataSetTool
from neuralNetwork.feedForwardNeuralNetwork import NeuralNetwork
from neuralNetwork.structure.layer import Layer
from numberGenerator.bounds import Bounds

np.set_printoptions(suppress=True)

dataSetTool = DataSetTool()
fileName = '../../dataSet/pima-indians-diabetes/pima-indians-diabetes.data'
training, generalization, testing = dataSetTool.getPrimaIndiansDiabetesSets(fileName)

plt.xlabel('Iterations')
plt.ylabel('Error')
plt.ion()

l_rate = 0.1

bounds = Bounds(-1, 1)

inputLayer = Layer(bounds, size = len(training[0][0]), prev = None, l_rate = l_rate, bias = True, label = "Input layer")
hiddenLayer = Layer(bounds, size = 20, prev = inputLayer, l_rate = l_rate, bias = True, label = "Hidden layer")
outputLayer = Layer(bounds, size = len(training[0][1]), prev = hiddenLayer, l_rate = l_rate, bias = False, label = "Output layer")

fnn = NeuralNetwork()
fnn.appendLayer(inputLayer)
fnn.appendLayer(hiddenLayer)
fnn.appendLayer(outputLayer)