After my seemingly silly troubles installing htm.core (i ran pip install cmake, then pip install htm.core worked fine) & watching all of HTM school, I figured a good place to start would be recoding the python examples cell by cell in Jupyter so I can understand each step of the process, what each object does and why, parameters etc.
The Mnist example works beautifully, and I gained some good understanding of how the shapes, spatial pooler etc. pieces together.
Since HTM’s real strength is temporal data, I tried recreating together the hotgym example cell by cell, works great up until the training loop. Specifically:
RuntimeError Traceback (most recent call last)
in
28
29 # make prediction, then train the predictor accordingly
—> 30 pdf = predictor.infer( tm.getActiveCells() )
31 for n in (1,5):
32 if pdf[n]:RuntimeError: CHECK FAILED: “dimensions_ != 0” Classifier: must call
learn
beforeinfer
.
This same error occurs when I run the original hotgym.py directly from the cloned repo, as well as my retyped Jupyter version. Since the error’s on “predictor.infer()” I called help(predictor) since I couldn’t find a matching page in the docs; I attached most of the help as an image.
It lists some example usage of Predictor objects:
Example Usage:
 # Predict 1 and 2 time steps into the future.

 # Make a sequence of 4 random SDRs, each SDR has 1000 bits and 2% sparsity.
 sequence = [ SDR( 1000 ).randomize( 0.02 ) for i in range(4) ]

 # Make category labels for the sequence.
 labels = [ 4, 5, 6, 7 ]

 # Make a Predictor and train it.
 pred = Predictor([ 1, 2 ])
 pred.learn( 0, sequence[0], labels[0] )
 pred.learn( 1, sequence[1], labels[1] )
 pred.learn( 2, sequence[2], labels[2] )
 pred.learn( 3, sequence[3], labels[3] )

 # Give the predictor partial information, and make predictions
 # about the future.
 pred.reset()
 A = pred.infer( sequence[0] )
 numpy.argmax( A[1] ) > labels[1]
 numpy.argmax( A[2] ) > labels[2]

 B = pred.infer( sequence[1] )
 numpy.argmax( B[1] ) > labels[2]
 numpy.argmax( B[2] ) > labels[3]
I notice here that it does indeed call Predictor.learn() before Predictor.infer(), so I see why the error gripes at me so; however, I’m not sure where to shoehorn a predictor.learn() method into hotgym.py’s training loop.
Considering the example code, I wonder if the function of predictor.learn() is being handled somewhere within the SpatialPooler.compute() and subsequent TemporalMemory.compute() methods in the loop, both of which have the parameter ‘learn=True’.
I’m tantalizingly close to recreating this interesting HTM timeseries analysis, but this is a strange sticking point that I haven’t seen mentioned on the forums. Is there something wrong with my install, perhaps? For reference, I’m on OS Mojave 10.14 python=3.7.4, installed with pip according to community instructions.
Any insight on where I’ve gone astray (or where to go from here!) would be greatly welcomed.