How to save the TemporalMemory parameters or reuse it?

Hi, Developers,

I read snippet from which shows the way to save the SpatialPooler parameter in the file.

My question is how to save TemporalMemory parameters like saving SpatialPooler parameters? or is it not necessary to save TemporalMemory parameters?

I understand the HTM model will vary and evolve according to the inputs. In my scenario, I want to train the HTM model with the given data, then save the model in one procedure Firstly. Then use the saved model to predict another validation input in another procedure.

What if I call ModelFactory.create to get a model, how to save the parameters or reload?

Looking forward to reply.

You should be able to save the TemporalMemory instance the same way as SpatialPooler using the method you linked to above. However…

This is now how you could resurrect the models. You are mixing the two serialization methods. There is an old version in the OPF, that’s the one that uses ModelFactory.create. It’s not the same thing as writeToFile you are using above. The deprecated serialization method pickles objects at the OPF level, so you would save the OPF HtmPredictionModel instance, which contains the algorithms and cell states and will do the work for you.

If you use the new way, you’ll have to save the individual states yourself and put them back together when they are brought back to life. This isn’t a hard task, it just takes some work and trial and error.

In any case, saving doesn’t just save the parameters (which you can easily do manually if you want), it also saves the state of the cells and permanences between them.

@rhyolight in the nupic.core we have c++ version of spatialPooler and TemporaryPooler, and in Python we have spatial_pooler and temporal_pooler. I really do not know if they are different? If yes, why?
Can you explain me? Thanks

I don’t think there is a temporal_pooler in python is there?

Thanks for your explanation! I will follow these clue for my subsequent experiment.

Are you referring to TemporalMemory in python?

@rhyolight sorry temporalPooler in htmresearch. Here I reference temporal_memory, but I am also interested in how different are spatial_pooler in c++ and python version?

They are not functionally different. I don’t know the details, but the C++ code has been optimized for speed.