Example #1
0
def test(num_tests):
    global training_inputs, temp_training_outputs, test_inputs, test_outputs
    correct = 0
    incorrect = 0

    # Test NN amount of times user specifies with num_tests
    for i in range(num_tests):
        # Get random test data
        r = randint(0, 59999)
        # Get test data in correct format
        new_test_input = np.array([[0.0 for x in range(784)]])
        temp = test_inputs[:, r]
        for j in range(784):
            new_test_input[0][j] = temp[j]
        new_test_input = new_test_input.T

        # Get NN's guess for input
        nnGuess = NeuralNetwork.think(NumberNet, test_input=new_test_input)

        # Log test results
        if test_outputs[r] == nnGuess:
            correct += 1
        else:
            incorrect += 1

    # Print test results
    print("Correct: " + str(correct))
    print("Incorrect: " + str(incorrect))
Example #2
0
def testWithInput(input_from_user):
    nnGuess = NeuralNetwork.think(NumberNet, test_input=input_from_user)
    print("My guess is... " + str(nnGuess))