@@ -0,0 +1,2386 @@
+# -*- coding: utf-8 -*-%0A%0Aimport numpy as np%0A%0Aclass neuralNet(object):%0A    def __init__(self):%0A        %0A        #   Parameters%0A        self.inputSize  = len(inputData%5B1,:%5D)%0A        self.outputSize = 1%0A        self.hiddenSize = 4%0A        %0A        #   Weights%0A        self.weight1 = np.random.rand(self.inputSize, self.hiddenSize)%0A        self.weight2 = np.random.rand(self.hiddenSize, self.outputSize)%0A        %0A    def forward(self, inputData):%0A        #   Forward propagation through network%0A        self.z1     = np.dot(inputData, self.weight1)%0A        self.z2     = self.sigmoid(self.z1)%0A        self.z3     = np.dot(self.z2, self.weight2)%0A        output      = self.sigmoid(self.z3)%0A        return output%0A    %0A    def backward(self, inputData, trainData, output):%0A        #   backwards propagation through network%0A        self.outputError     = trainData - output%0A        self.outputDelta     = self.outputError * self.sigmoidPrime(output)%0A        %0A        self.z2Error    = self.outputDelta.dot(self.weight2.T)%0A        self.z2Delta    = self.z2Error * self.sigmoidPrime(self.z2)%0A        %0A        self.weight1    += inputData.T.dot(self.z2Delta)%0A        self.weight2    += self.z2.T.dot(self.outputDelta)%0A        %0A    def sigmoid(self, x):%0A        #   Sigmoid transfer function%0A        transferFunction = 1/(1+np.exp(-x))%0A        return transferFunction%0A    %0A    def sigmoidPrime(self, x):%0A        #   First derivative of sigmoid function%0A        sigmoidPrime = x*(1-x)%0A        return sigmoidPrime%0A    %0A    def train(self, inputSize, trainData, iterations):%0A        for j in range(iterations):%0A            output = self.forward(inputSize)%0A            self.backward(inputData, trainData, output)%0A%0Aif __name__ == %22__main__%22:%0A    %0A    inputDataFile = %22input.csv%22%0A    trainDataFile = %22train.csv%22%0A    %0A    inputData = np.genfromtxt(inputDataFile, delimiter = ',')%0A    trainData = np.genfromtxt(trainDataFile, delimiter = ',')%0A    trainData = np.transpose(%5BtrainData%5D)%0A    %0A    #   Create neural network with above data%0A    nn = neuralNet()%0A    %0A    #   Number of iterations over which to train network%0A    iMax = 1000%0A    %0A    nn.train(inputData, trainData, iMax)%0A    %0A    print(%22Input: %5Cn%22, inputData)%0A    print(%22Actual Output: %5Cn%22, trainData)%0A    print(%22Predicted Output: %5Cn%22, nn.forward(inputData))%0A    print(%22Loss: %22, np.mean(np.square(trainData - nn.forward(inputData))))%0A    print()%0A

Create neuralNet.py