Problem running newly saved / loaded SP & TM



I got only value -zero.Because I used different classifiers My working code as saving :

with open("out_sp.tmp", "wb") as f1:
with open("out_tm.tmp", "wb") as f2:
with open("out_classifier.tmp", "wb") as f3:
with open("out_classifier1.tmp", "wb") as f4:
with open("out_classifier2.tmp", "wb") as f5:

And then my loading :

with open(“out_sp.tmp”, “rb”) as f1:
sp2 = SpatialPooler.readFromFile(f1)
with open(“out_tm.tmp”, “rb”) as f1:
tm2 = TemporalMemory.readFromFile(f1)
with open(“out_classifier.tmp”, “rb”) as f2:
classifier4 = SDRClassifier.readFromFile(f2)
with open(“out_classifier1.tmp”, “rb”) as f3:
classifier5= SDRClassifier.readFromFile(f3)
with open(“out_classifier2.tmp”, “rb”) as f4:
classifier6= SDRClassifier.readFromFile(f4)


Not the end of the history:) Should I serialize SDRClassifier? Because I got the different result if I serialized classifier or didn’t serialize?

Thanks a lot !


I’m using the OPF for model saving & loading within a loop. Not sure if this helps at all but here’s the function I have for it:


Thanx a lot. Unfortunately, I can’t use OPF models, because I use 3 classifiers on one model.
These is my code :

if (count%100) == 0:
with open(“out_sp.tmp”, “wba”) as f1:
with open(“out_tm.tmp”, “wba”) as f2:
with open(“out_classifier.tmp”, “a”) as f3:
with open(“out_classifier1.tmp”, “a”) as f4:
with open(“out_classifier2.tmp”, “a”) as f5:

What is your mind about this code? I have a different result if have common classifier or if I serialize classifier. I don’t understand why.


@scott should @sergey serialize the classifier?


Maybe some problems about file size?


I’m still confused about your problem. Maybe I can help better if you post your complete program code somewhere so I can run it and see the issues myself.


good idea. Few minutes .


This is my code ,when I saved model:
This is my code when i loaded learning model:

When I didn’t serialize classifier , I had not prediction in general. If I used these two functions in one script , I had normal prediction with common classifier. If I serialized classifier I had bad prediction .

Thanks for your help !


Thanks for posting. I’m actually on vacation right now and will look at this when I get back into the office (sorry!).


Sorry for interrupt your vacation. Maybe different members on forum can look code.

Have a good vacation !

Thank you very much


If serializing and deserializing the classifier results in different predictions then there is probably a bug.


In my code or in nupic. Did you look at my code?Maybe it’s my fault.