|
19 | 19 | import random |
20 | 20 | import numpy as np |
21 | 21 | import os |
| 22 | +import sys |
22 | 23 |
|
23 | 24 | from htm.bindings.algorithms import SpatialPooler, Classifier |
24 | 25 | from htm.bindings.sdr import SDR, Metrics |
@@ -73,7 +74,7 @@ def load_images(file_name): |
73 | 74 |
|
74 | 75 | return train_labels, train_images, test_labels, test_images |
75 | 76 |
|
76 | | -# these parameters can be improved using parameter optimization, |
| 77 | +# These parameters can be improved using parameter optimization, |
77 | 78 | # see py/htm/optimization/ae.py |
78 | 79 | # For more explanation of relations between the parameters, see |
79 | 80 | # src/examples/mnist/MNIST_CPP.cpp |
@@ -114,7 +115,7 @@ def main(parameters=default_parameters, argv=None, verbose=True): |
114 | 115 | potentialPct = parameters['potentialPct'], |
115 | 116 | globalInhibition = True, |
116 | 117 | localAreaDensity = parameters['localAreaDensity'], |
117 | | - stimulusThreshold = int(round(parameters['stimulusThreshold'])), #param is requested to be an integer, but param optimization might find fractional value, so round it |
| 118 | + stimulusThreshold = int(round(parameters['stimulusThreshold'])), |
118 | 119 | synPermInactiveDec = parameters['synPermInactiveDec'], |
119 | 120 | synPermActiveInc = parameters['synPermActiveInc'], |
120 | 121 | synPermConnected = parameters['synPermConnected'], |
@@ -145,13 +146,11 @@ def main(parameters=default_parameters, argv=None, verbose=True): |
145 | 146 | sp.compute( enc, False, columns ) |
146 | 147 | if lbl == np.argmax( sdrc.infer( columns ) ): |
147 | 148 | score += 1 |
148 | | - |
149 | 149 | score = score / len(test_data) |
150 | 150 |
|
151 | | - assert score >= 0.951, "MNIST: score should be better than 95.1%" |
152 | 151 | print('Score:', 100 * score, '%') |
153 | | - return score |
| 152 | + return score < 0.95 |
154 | 153 |
|
155 | 154 |
|
156 | 155 | if __name__ == '__main__': |
157 | | - main() |
| 156 | + sys.exit( main() ) |
0 commit comments