dtype=float) # Input: [HoursSleep, HoursStudy] testY_orig = np.array([[70], [89], [85], [75]], dtype=float) # Output: [Test Score] #Nomalize data: trainX = trainX_orig / np.amax(trainX_orig, axis=0) trainY = trainY_orig / 100 #Max test score is 100 #Nomalize data by max of training data: testX = testX_orig / np.amax(trainX, axis=0) testY = testY_orig / 100 #Max test score is 100 NN = NeuralNetwork(0.0001) # # Make sure our gradients are correct: numgrad = util.computeNumericalGradient(NN, trainX, trainY) grad = NN.computeGradients(trainX, trainY) norm = np.linalg.norm(grad - numgrad) / np.linalg.norm(grad + numgrad) print(norm) # Should be less than 1e-8: T = Trainer(NN) T.train(trainX, trainY, testX, testY) # util.showCostPlot(T.J, T.testJ) #Generate Test Data hoursSleep = np.linspace(0, 10, 100) hoursStudy = np.linspace(0, 5, 100) # Normalize data hoursSleepNorm = hoursSleep / 10. hoursStudyNorm = hoursStudy / 5. #Create 2-d versions of input for plotting a, b = np.meshgrid(hoursSleepNorm, hoursStudyNorm)