123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- import numpy as np
- from nn import NeuralNetwork
- # _
- # | |
- # _
- # | |
- # _
- # 1
- # 2 3
- # 4
- # 5 6
- # 7
- nn = NeuralNetwork(input_layer_size=7, hidden_layer_size=16, output_layer_size=10)
- nn.load('test.npz')
- test_data = [0.0, 0.0, 0.98, 0.0, 0.0, 0.99, 0.0] #1
- output = nn.get(test_data)
- print ("Test: 1")
- print (output)
- index = np.argmax(output)
- predict = np.argmax(output)+1
- confidence = round(output[0][index][0] * 100, 2)
- print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
- test_data = [0.89, 0.0, 0.92, 0.97, 0.87, 0.0, 0.87] #2
- output = nn.get(test_data)
- print ("Test: 2")
- print (output)
- index = np.argmax(output)
- predict = np.argmax(output)+1
- confidence = round(output[0][index][0] * 100, 2)
- print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
- test_data = [1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0] #3
- output = nn.get(test_data)
- print ("Test: 3")
- print (output)
- index = np.argmax(output)
- predict = np.argmax(output)+1
- confidence = round(output[0][index][0] * 100, 2)
- print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
- test_data = [0.08, 0.97, 0.98, 0.97, 0.0, 0.89, 0.12] #4
- output = nn.get(test_data)
- print ("Test: 4")
- print (output)
- index = np.argmax(output)
- predict = np.argmax(output)+1
- confidence = round(output[0][index][0] * 100, 2)
- print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
- test_data = [0.82, 0.97, 0.09, 0.97, 0.0, 0.89, 0.92] #5
- output = nn.get(test_data)
- print ("Test: 5")
- print (output)
- index = np.argmax(output)
- predict = np.argmax(output)+1
- confidence = round(output[0][index][0] * 100, 2)
- print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
- test_data = [0.82, 0.97, 0.09, 0.97, 0.89, 0.89, 0.92] #6
- output = nn.get(test_data)
- print ("Test: 6")
- print (output)
- index = np.argmax(output)
- predict = np.argmax(output)+1
- confidence = round(output[0][index][0] * 100, 2)
- print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
- test_data = [0.82, 0.09, 0.92, 0.09, 0.08, 0.91, 0.07] #7
- output = nn.get(test_data)
- print ("Test: 7")
- print (output)
- index = np.argmax(output)
- predict = np.argmax(output)+1
- confidence = round(output[0][index][0] * 100, 2)
- print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
- test_data = [0.82, 0.97, 0.91, 0.97, 0.89, 0.89, 0.92] #8
- output = nn.get(test_data)
- print ("Test: 8")
- print (output)
- index = np.argmax(output)
- predict = np.argmax(output)+1
- confidence = round(output[0][index][0] * 100, 2)
- print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
- test_data = [0.82, 0.97, 0.91, 0.97, 0.08, 0.89, 0.92] #9
- output = nn.get(test_data)
- print ("Test: 9")
- print (output)
- index = np.argmax(output)
- predict = np.argmax(output)+1
- confidence = round(output[0][index][0] * 100, 2)
- print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
- test_data = [0.8, 1.0, 0.98, 0.0, 0.89, 0.89, 0.99] #0
- output = nn.get(test_data)
- print ("Test: 0")
- print (output)
- index = np.argmax(output)
- predict = np.argmax(output)+1
- confidence = round(output[0][index][0] * 100, 2)
- print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
- test_data = [0.1, 0.12, 0.15, 0.05, 0.09, 0.098, 0.11] # Nothing
- output = nn.get(test_data)
- print ("Test: Nothing")
- print (output)
- index = np.argmax(output)
- predict = np.argmax(output)+1
- confidence = round(output[0][index][0] * 100, 2)
- print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
- test_data = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] # Nothing
- output = nn.get(test_data)
- print ("Test: Absolutely nothing :)")
- print (output)
- index = np.argmax(output)
- predict = np.argmax(output)+1
- confidence = round(output[0][index][0] * 100, 2)
- print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
|