I am performing a cross validation (I know this is not was HTM is made for…but we have to compare performances…so what to do )
So I have 7 trainings and test sets.
After finishing my training for one model, I save it into a list.
When I trained all models I pickle the list with a simple expression:
with open("model.pkl", "w") as f:
pickle.dump(models, f)
where models is the list containing all my models.
All that works fine. (even saving the models in a list and using just one of them afterwards is working).
Now my problem (for which i was not able to find a solution here in the forum even with hours of reading )
I load the models from the pickle again with:
with open("model.pkl") as f:
reloaded_models = pickle.load(f)
when I now want to make a prediction I get the following error:
assert not self.__restoringFromState
AssertionError
in nupic/frameworks/opf/htm_prediction_model.py"
How can I fix this bug?
I really need my models in pickle… soo any help would be really appreciated.
unfortunately no… I read both before even opening this new topic… but they doen’t help me.
The thing is:
I calculate the models.
I can work with all the results and to prediction and everything. But as soon as I pickle and reload them i get this error…
I also checked the code in nupic/frameworks/opf/htm_prediction_model.py … I tried to manually set the __restoringFromState variable. But even this does not work…
Did you try the new way of saving using writeToFile and readFromFile? If you can’t just put models in a list and pickle them, you’ll need to keep track of the sp and tm files separately for each model.
this is clear! But afterwards??? I do have the instances for SP and TM.
How can I build a whole model with these??
I want to do some more predictions and tests.
Can you create an OPF model in the same way, then try to replace the algorithm instances in the model that you’ve resurrected from disk? This is hacky, but I would try it. See:
replace the SP model._getSPREgioon().getSelf()._sfdr with the resurrected SP instance
replace the TM model._getTPRegion().getSelf(). _tfdr with the resurrected TM instance
I’m not sure if this will work, I have never tried it!