I got only value -zero.Because I used different classifiers My working code as saving :
with open("out_sp.tmp", "wb") as f1:
sp.writeToFile(f1)
with open("out_tm.tmp", "wb") as f2:
tm.writeToFile(f2)
with open("out_classifier.tmp", "wb") as f3:
classifier.writeToFile(f3)
with open("out_classifier1.tmp", "wb") as f4:
classifier1.writeToFile(f4)
with open("out_classifier2.tmp", "wb") as f5:
classifier2.writeToFile(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)
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:
sp.writeToFile(f1)
with open(“out_tm.tmp”, “wba”) as f2:
tm.writeToFile(f2)
with open(“out_classifier.tmp”, “a”) as f3:
classifier.writeToFile(f3)
with open(“out_classifier1.tmp”, “a”) as f4:
classifier1.writeToFile(f4)
with open(“out_classifier2.tmp”, “a”) as f5:
classifier2.writeToFile(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.
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.
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 .
@Sergey I looked at your code and it looks like you need to serialize the last 100 records from the stream.
In the learning stage code you are saving a checkpoint every 100 records (lines 556-566) but you are missing the last 100 records. You are also exiting the loop without serializing the results on line 448.
You need to add the serialization code to outside the loop making sure the last 100 records are saved. See patch below:
--- learning_stage.py 2018-07-24 07:46:20.000000000 -0700
+++ learning_stage_new.py 2018-07-24 07:52:20.000000000 -0700
@@ -564,6 +564,18 @@
classifier1.writeToFile(f4)
with open("out_classifier2.tmp", "w") as f5:
classifier2.writeToFile(f5)
+
+ # Save last batch
+ with open("out_sp.tmp", "w") as f1:
+ sp.writeToFile(f1)
+ with open("out_tm.tmp", "w") as f2:
+ tm.writeToFile(f2)
+ with open("out_classifier.tmp", "w") as f3:
+ classifier.writeToFile(f3)
+ with open("out_classifier1.tmp", "w") as f4:
+ classifier1.writeToFile(f4)
+ with open("out_classifier2.tmp", "w") as f5:
+ classifier2.writeToFile(f5)
# builder = SpatialPoolerProto.new_message()
# sp.write(builder)
# serializedMessage = builder.to_bytes_packed()