test.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import numpy as np
  2. from nn import NeuralNetwork
  3. # _
  4. # | |
  5. # _
  6. # | |
  7. # _
  8. # 1
  9. # 2 3
  10. # 4
  11. # 5 6
  12. # 7
  13. nn = NeuralNetwork(input_layer_size=7, hidden_layer_size=16, output_layer_size=10)
  14. nn.load('test.npz')
  15. test_data = [0.0, 0.0, 0.98, 0.0, 0.0, 0.99, 0.0] #1
  16. output = nn.get(test_data)
  17. print ("Test: 1")
  18. print (output)
  19. index = np.argmax(output)
  20. predict = np.argmax(output)+1
  21. confidence = round(output[0][index][0] * 100, 2)
  22. print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
  23. test_data = [0.89, 0.0, 0.92, 0.97, 0.87, 0.0, 0.87] #2
  24. output = nn.get(test_data)
  25. print ("Test: 2")
  26. print (output)
  27. index = np.argmax(output)
  28. predict = np.argmax(output)+1
  29. confidence = round(output[0][index][0] * 100, 2)
  30. print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
  31. test_data = [1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0] #3
  32. output = nn.get(test_data)
  33. print ("Test: 3")
  34. print (output)
  35. index = np.argmax(output)
  36. predict = np.argmax(output)+1
  37. confidence = round(output[0][index][0] * 100, 2)
  38. print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
  39. test_data = [0.08, 0.97, 0.98, 0.97, 0.0, 0.89, 0.12] #4
  40. output = nn.get(test_data)
  41. print ("Test: 4")
  42. print (output)
  43. index = np.argmax(output)
  44. predict = np.argmax(output)+1
  45. confidence = round(output[0][index][0] * 100, 2)
  46. print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
  47. test_data = [0.82, 0.97, 0.09, 0.97, 0.0, 0.89, 0.92] #5
  48. output = nn.get(test_data)
  49. print ("Test: 5")
  50. print (output)
  51. index = np.argmax(output)
  52. predict = np.argmax(output)+1
  53. confidence = round(output[0][index][0] * 100, 2)
  54. print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
  55. test_data = [0.82, 0.97, 0.09, 0.97, 0.89, 0.89, 0.92] #6
  56. output = nn.get(test_data)
  57. print ("Test: 6")
  58. print (output)
  59. index = np.argmax(output)
  60. predict = np.argmax(output)+1
  61. confidence = round(output[0][index][0] * 100, 2)
  62. print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
  63. test_data = [0.82, 0.09, 0.92, 0.09, 0.08, 0.91, 0.07] #7
  64. output = nn.get(test_data)
  65. print ("Test: 7")
  66. print (output)
  67. index = np.argmax(output)
  68. predict = np.argmax(output)+1
  69. confidence = round(output[0][index][0] * 100, 2)
  70. print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
  71. test_data = [0.82, 0.97, 0.91, 0.97, 0.89, 0.89, 0.92] #8
  72. output = nn.get(test_data)
  73. print ("Test: 8")
  74. print (output)
  75. index = np.argmax(output)
  76. predict = np.argmax(output)+1
  77. confidence = round(output[0][index][0] * 100, 2)
  78. print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
  79. test_data = [0.82, 0.97, 0.91, 0.97, 0.08, 0.89, 0.92] #9
  80. output = nn.get(test_data)
  81. print ("Test: 9")
  82. print (output)
  83. index = np.argmax(output)
  84. predict = np.argmax(output)+1
  85. confidence = round(output[0][index][0] * 100, 2)
  86. print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
  87. test_data = [0.8, 1.0, 0.98, 0.0, 0.89, 0.89, 0.99] #0
  88. output = nn.get(test_data)
  89. print ("Test: 0")
  90. print (output)
  91. index = np.argmax(output)
  92. predict = np.argmax(output)+1
  93. confidence = round(output[0][index][0] * 100, 2)
  94. print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
  95. test_data = [0.1, 0.12, 0.15, 0.05, 0.09, 0.098, 0.11] # Nothing
  96. output = nn.get(test_data)
  97. print ("Test: Nothing")
  98. print (output)
  99. index = np.argmax(output)
  100. predict = np.argmax(output)+1
  101. confidence = round(output[0][index][0] * 100, 2)
  102. print (f'Predict: {predict}; Confidence: {confidence}%\r\n')
  103. test_data = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] # Nothing
  104. output = nn.get(test_data)
  105. print ("Test: Absolutely nothing :)")
  106. print (output)
  107. index = np.argmax(output)
  108. predict = np.argmax(output)+1
  109. confidence = round(output[0][index][0] * 100, 2)
  110. print (f'Predict: {predict}; Confidence: {confidence}%\r\n')