def testWriteRead(self):
    tm1 = TemporalMemory(
      columnDimensions=(32,),
      cellsPerColumn=4,
      activationThreshold=3,
      initialPermanence=0.21,
      connectedPermanence=0.50,
      minThreshold=2,
      maxNewSynapseCount=3,
      permanenceIncrement=0.1,
      permanenceDecrement=0.1,
      predictedSegmentDecrement=0.0,
      seed=42
    )

    self.serializationTestPrepare(tm1)

    proto1 = TemporalMemoryProto_capnp.TemporalMemoryProto.new_message()
    tm1.write(proto1)

    # Write the proto to a temp file and read it back into a new proto
    with tempfile.TemporaryFile() as f:
      proto1.write(f)
      f.seek(0)
      proto2 = TemporalMemoryProto_capnp.TemporalMemoryProto.read(f)

    # Load the deserialized proto
    tm2 = TemporalMemory.read(proto2)

    self.assertEqual(tm1, tm2)
    self.serializationTestVerify(tm2)
Beispiel #2
0
  def testWriteRead(self):
    tm1 = TemporalMemory(
      columnDimensions=(32,),
      cellsPerColumn=4,
      activationThreshold=3,
      initialPermanence=0.21,
      connectedPermanence=0.50,
      minThreshold=2,
      maxNewSynapseCount=3,
      permanenceIncrement=0.1,
      permanenceDecrement=0.1,
      predictedSegmentDecrement=0.0,
      seed=42
    )

    self.serializationTestPrepare(tm1)

    proto1 = TemporalMemoryProto_capnp.TemporalMemoryProto.new_message()
    tm1.write(proto1)

    # Write the proto to a temp file and read it back into a new proto
    with tempfile.TemporaryFile() as f:
      proto1.write(f)
      f.seek(0)
      proto2 = TemporalMemoryProto_capnp.TemporalMemoryProto.read(f)

    # Load the deserialized proto
    tm2 = TemporalMemory.read(proto2)

    self.assertEqual(tm1, tm2)
    self.serializationTestVerify(tm2)
Beispiel #3
0
    def testWriteTestFile(self):
        tm = TemporalMemory(columnDimensions=(32, ),
                            cellsPerColumn=4,
                            activationThreshold=3,
                            initialPermanence=0.21,
                            connectedPermanence=0.50,
                            minThreshold=2,
                            maxNewSynapseCount=3,
                            permanenceIncrement=0.1,
                            permanenceDecrement=0.1,
                            predictedSegmentDecrement=0.0,
                            seed=42)

        self.serializationTestPrepare(tm)
        proto = TemporalMemoryProto_capnp.TemporalMemoryProto.new_message()
        tm.write(proto)
        with open("TemporalMemorySerializationWrite.tmp", "w") as f:
            proto.write(f)
Beispiel #4
0
  def testWriteTestFile(self):
    tm = TemporalMemory(
      columnDimensions=(32,),
      cellsPerColumn=4,
      activationThreshold=3,
      initialPermanence=0.21,
      connectedPermanence=0.50,
      minThreshold=2,
      maxNewSynapseCount=3,
      permanenceIncrement=0.1,
      permanenceDecrement=0.1,
      predictedSegmentDecrement=0.0,
      seed=42
    )

    self.serializationTestPrepare(tm)
    proto = TemporalMemoryProto_capnp.TemporalMemoryProto.new_message()
    tm.write(proto)
    with open("TemporalMemorySerializationWrite.tmp", "w") as f:
      proto.write(f)