numenta / nupic-legacy

Numenta Platform for Intelligent Computing is an implementation of Hierarchical Temporal Memory (HTM), a theory of intelligence based strictly on the neuroscience of the neocortex.
http://numenta.org/
GNU Affero General Public License v3.0
6.34k stars 1.56k forks source link

Serializing multiple times with capnproto, KjException: capnp/dynamic.c++:1777: failed #3805

Open ghost opened 6 years ago

ghost commented 6 years ago
    from nupic.frameworks.opf.htm_prediction_model import HTMPredictionModel
    def test_mutliple_rounds_opf_serialization(self):
        for i in range(500):
            self.anomaly_model.process_sample(self.source.next())

        self.anomaly_model.save(CHECKPOINT_DIR)
        restored_model = AnomalyModel.load(CHECKPOINT_DIR)

        restored_model.save(CHECKPOINT_DIR)
        restored_model = AnomalyModel.load(CHECKPOINT_DIR)

        restored_model.save(CHECKPOINT_DIR)
        AnomalyModel.load(CHECKPOINT_DIR)

    def test_multiple_rounds_serialization(self):
        for i in range(500):
            sample = self.source.next()
            self.anomaly_model.process_sample(sample)

        proto1 = HTMPredictionModel.getSchema()
        builder = proto1.new_message()
        self.anomaly_model.htm_model.write(builder)
        data1 = builder.to_bytes_packed()

        proto2 = HTMPredictionModel.getSchema()
        reader = proto2.from_bytes_packed(data1)
        model = HTMPredictionModel.read(reader)

        proto3 = HTMPredictionModel.getSchema()
        builder = proto3.new_message()
        model.write(builder)
        data2 = builder.to_bytes_packed()
        self.assertEqual(data2, data1)

Both of these tests return the same error. It looks like it's not possible to serialize models more than once?

Edit: It seems this error doesn't show up as long as you compute samples in between serializing. I can't see why we wouldn't do that, maybe this issue doesn't matter.

KjException: capnp/dynamic.c++:1777: failed: expected reader.type == BOOL; Value type mismatch. stack: 0x7f6162dcd0a8 0x7f6162ce04ad 0x7f6162ce215d 0x7f6162c49928 0x7f6162ce0bff 0x7f6162ce215d 0x7f6162c49928 0x7f6162cdc631 0x7f6162cdf066 0x7f6162c762ee 0x7f617ce779df 0x7f617cee158b 0x7f617cee3c3e 0x7f617cee3c3e 0x7f617cee3c3e 0x7f617cee3c3e 0x7f617cee6b80 0x7f617ce5c955 0x7f617ce2a983 0x7f616103af72 0x7f616103b3bd 0x7f6160ff0d1f 0x7f61610ae224 0x7f61610c6927 0x7f617cee3b16 0x7f617cee3c3e 0x7f617cee3c3e 0x7f617cee3c3e 0x7f617cee3c3e 0x7f617cee6b80 0x7f617ce5c955

HAPPY VALENTINES DAY

rhyolight commented 6 years ago

Interesting. Will keep this report around, but probably will not prioritize for an immediate fix.

ghost commented 6 years ago

Just bumping this issue for visualization, it is not important, today I was writing some serialization tests and got this error, took me a while to remember that you cannot serialize/deserialize/serialize without processing samples in between.

It's not an important bug, but some warning somewhere might help other people who run into this and don't just get lucky and stumble into this fact.

rhyolight commented 6 years ago

I just released NuPIC 1.0.5 like 5 minutes ago. You might try with this new release, because we updated the CAPNP version.