@classmethod<EOL><INDENT>def read(cls, proto):<DEDENT>
assert proto.version == TM_VERSION<EOL>obj = object.__new__(cls)<EOL>obj._random = Random()<EOL>obj._random.read(proto.random)<EOL>obj.numberOfCols = int(proto.numberOfCols)<EOL>obj.cellsPerColumn = int(proto.cellsPerColumn)<EOL>obj._numberOfCells = obj.numberOfCols * obj.cellsPerColumn<EOL>obj.initialPerm = numpy.float32(proto.initialPerm)<EOL>obj.connectedPerm = numpy.float32(proto.connectedPerm)<EOL>obj.minThreshold = int(proto.minThreshold)<EOL>obj.newSynapseCount = int(proto.newSynapseCount)<EOL>obj.permanenceInc = numpy.float32(proto.permanenceInc)<EOL>obj.permanenceDec = numpy.float32(proto.permanenceDec)<EOL>obj.permanenceMax = numpy.float32(proto.permanenceMax)<EOL>obj.globalDecay = numpy.float32(proto.globalDecay)<EOL>obj.activationThreshold = int(proto.activationThreshold)<EOL>obj.doPooling = proto.doPooling<EOL>obj.segUpdateValidDuration = int(proto.segUpdateValidDuration)<EOL>obj.burnIn = int(proto.burnIn)<EOL>obj.collectStats = proto.collectStats<EOL>obj.verbosity = int(proto.verbosity)<EOL>obj.pamLength = int(proto.pamLength)<EOL>obj.maxAge = int(proto.maxAge)<EOL>obj.maxInfBacktrack = int(proto.maxInfBacktrack)<EOL>obj.maxLrnBacktrack = int(proto.maxLrnBacktrack)<EOL>obj.maxSeqLength = int(proto.maxSeqLength)<EOL>obj.maxSegmentsPerCell = proto.maxSegmentsPerCell<EOL>obj.maxSynapsesPerSegment = proto.maxSynapsesPerSegment<EOL>obj.outputType = proto.outputType<EOL>obj.activeColumns = [int(col) for col in proto.activeColumns]<EOL>obj.cells = [[] for _ in range(len(proto.cells))]<EOL>for columnSegments, columnSegmentsProto in zip(obj.cells, proto.cells):<EOL><INDENT>columnSegments.extend([[] for _ in range(len(columnSegmentsProto))])<EOL>for cellSegments, cellSegmentsProto in zip(columnSegments,<EOL>columnSegmentsProto):<EOL><INDENT>for segmentProto in cellSegmentsProto:<EOL><INDENT>segment = Segment.read(segmentProto, obj)<EOL>cellSegments.append(segment)<EOL><DEDENT><DEDENT><DEDENT>obj.lrnIterationIdx = int(proto.lrnIterationIdx)<EOL>obj.iterationIdx = int(proto.iterationIdx)<EOL>obj.segID = int(proto.segID)<EOL>obj.pamCounter = int(proto.pamCounter)<EOL>obj.collectSequenceStats = proto.collectSequenceStats<EOL>obj.resetCalled = proto.resetCalled<EOL>avgInputDensity = proto.avgInputDensity<EOL>if avgInputDensity < <NUM_LIT:0.0>:<EOL><INDENT>obj.avgInputDensity = None<EOL><DEDENT>else:<EOL><INDENT>obj.avgInputDensity = avgInputDensity<EOL><DEDENT>obj.learnedSeqLength = int(proto.learnedSeqLength)<EOL>obj.avgLearnedSeqLength = proto.avgLearnedSeqLength<EOL>obj._initEphemerals()<EOL>if proto.currentOutput.which() == "<STR_LIT:none>":<EOL><INDENT>obj.currentOutput = None<EOL><DEDENT>else:<EOL><INDENT>obj.currentOutput = numpy.array(proto.currentOutput.list,<EOL>dtype='<STR_LIT>')<EOL><DEDENT>for pattern in proto.prevLrnPatterns:<EOL><INDENT>obj.prevLrnPatterns.append([v for v in pattern])<EOL><DEDENT>for pattern in proto.prevInfPatterns:<EOL><INDENT>obj.prevInfPatterns.append([v for v in pattern])<EOL><DEDENT>for cellWrapperProto in proto.segmentUpdates:<EOL><INDENT>key = (cellWrapperProto.columnIdx, cellWrapperProto.cellIdx)<EOL>value = []<EOL>for updateWrapperProto in cellWrapperProto.segmentUpdates:<EOL><INDENT>segmentUpdate = SegmentUpdate.read(updateWrapperProto.segmentUpdate, obj)<EOL>value.append((int(updateWrapperProto.lrnIterationIdx), segmentUpdate))<EOL><DEDENT>obj.segmentUpdates[key] = value<EOL><DEDENT>numpy.copyto(obj.cellConfidence["<STR_LIT:t>"], proto.cellConfidenceT)<EOL>numpy.copyto(obj.cellConfidence["<STR_LIT>"], proto.cellConfidenceT1)<EOL>numpy.copyto(obj.cellConfidence["<STR_LIT>"],<EOL>proto.cellConfidenceCandidate)<EOL>numpy.copyto(obj.colConfidence["<STR_LIT:t>"], proto.colConfidenceT)<EOL>numpy.copyto(obj.colConfidence["<STR_LIT>"], proto.colConfidenceT1)<EOL>numpy.copyto(obj.colConfidence["<STR_LIT>"], proto.colConfidenceCandidate)<EOL>numpy.copyto(obj.lrnActiveState["<STR_LIT:t>"], proto.lrnActiveStateT)<EOL>numpy.copyto(obj.lrnActiveState["<STR_LIT>"], proto.lrnActiveStateT1)<EOL>numpy.copyto(obj.infActiveState["<STR_LIT:t>"], proto.infActiveStateT)<EOL>numpy.copyto(obj.infActiveState["<STR_LIT>"], proto.infActiveStateT1)<EOL>numpy.copyto(obj.infActiveState["<STR_LIT>"], proto.infActiveStateBackup)<EOL>numpy.copyto(obj.infActiveState["<STR_LIT>"],<EOL>proto.infActiveStateCandidate)<EOL>numpy.copyto(obj.lrnPredictedState["<STR_LIT:t>"], proto.lrnPredictedStateT)<EOL>numpy.copyto(obj.lrnPredictedState["<STR_LIT>"], proto.lrnPredictedStateT1)<EOL>numpy.copyto(obj.infPredictedState["<STR_LIT:t>"], proto.infPredictedStateT)<EOL>numpy.copyto(obj.infPredictedState["<STR_LIT>"], proto.infPredictedStateT1)<EOL>numpy.copyto(obj.infPredictedState["<STR_LIT>"],<EOL>proto.infPredictedStateBackup)<EOL>numpy.copyto(obj.infPredictedState["<STR_LIT>"],<EOL>proto.infPredictedStateCandidate)<EOL>obj.consolePrinterVerbosity = int(proto.consolePrinterVerbosity)<EOL>return obj<EOL>
Deserialize from proto instance.

        :param proto: (BacktrackingTMProto) the proto instance to read from