Example #1
0
    def initialize(self, inputs, outputs):
        """
    Initialize the self._tm if not already initialized. We need to figure out
    the constructor parameters for each class, and send it to that constructor.
    """
        if self._tm is None:
            # Create dict of arguments we will pass to the temporal memory class
            args = copy.deepcopy(self.__dict__)
            args["columnDimensions"] = (self.columnCount, )

            # Ensure we only pass in those args that are expected by this
            # implementation. This is important for SWIG'ified classes, such as
            # TemporalMemoryCPP, which don't take kwargs.
            expectedArgs = getConstructorArguments(self.temporalImp)[0]
            for arg in args.keys():
                if not arg in expectedArgs:
                    args.pop(arg)

            # Create the TM instance
            self._tm = createModel(self.temporalImp, **args)

            # numpy arrays we will use for some of the outputs
            self.activeState = numpy.zeros(self._tm.numberOfCells())
            self.previouslyPredictedCells = numpy.zeros(
                self._tm.numberOfCells())
Example #2
0
    def initialize(self):
        """
    Initialize the self._tm if not already initialized. We need to figure out
    the constructor parameters for each class, and send it to that constructor.
    """
        if self._tm is None:
            args = {
                "columnDimensions": (self.columnCount, ),
                "cellsPerColumn": self.cellsPerColumn,
                "activationThreshold": self.activationThreshold,
                "initialPermanence": self.initialPermanence,
                "connectedPermanence": self.connectedPermanence,
                "minThreshold": self.minThreshold,
                "maxNewSynapseCount": self.maxNewSynapseCount,
                "permanenceIncrement": self.permanenceIncrement,
                "permanenceDecrement": self.permanenceDecrement,
                "predictedSegmentDecrement": self.predictedSegmentDecrement,
                "formInternalBasalConnections":
                self.formInternalBasalConnections,
                "learnOnOneCell": self.learnOnOneCell,
                "maxSegmentsPerCell": self.maxSegmentsPerCell,
                "maxSynapsesPerSegment": self.maxSynapsesPerSegment,
                "seed": self.seed,
                "checkInputs": self.checkInputs,
            }

            # Ensure we only pass in those args that are expected by this
            # implementation. This is important for SWIG'ified classes, such as
            # TemporalMemoryCPP, which don't take kwargs.
            expectedArgs = getConstructorArguments(self.temporalImp)[0]
            for arg in args.keys():
                if not arg in expectedArgs:
                    args.pop(arg)

            # Create the TM instance.
            self._tm = createModel(self.implementation, **args)

            # Carry some information to the next time step.
            self.prevPredictiveCells = ()
            self.prevActiveExternalCells = ()
            self.prevActiveApicalCells = ()
Example #3
0
    def initialize(self, inputs, outputs):
        """
    Initialize the self._tm if not already initialized. We need to figure out
    the constructor parameters for each class, and send it to that constructor.
    """
        if self._tm is None:
            args = {
                "columnDimensions": (self.columnCount,),
                "cellsPerColumn": self.cellsPerColumn,
                "activationThreshold": self.activationThreshold,
                "initialPermanence": self.initialPermanence,
                "connectedPermanence": self.connectedPermanence,
                "minThreshold": self.minThreshold,
                "maxNewSynapseCount": self.maxNewSynapseCount,
                "permanenceIncrement": self.permanenceIncrement,
                "permanenceDecrement": self.permanenceDecrement,
                "predictedSegmentDecrement": self.predictedSegmentDecrement,
                "formInternalBasalConnections": self.formInternalBasalConnections,
                "learnOnOneCell": self.learnOnOneCell,
                "maxSegmentsPerCell": self.maxSegmentsPerCell,
                "maxSynapsesPerSegment": self.maxSynapsesPerSegment,
                "seed": self.seed,
                "checkInputs": self.checkInputs,
            }

            # Ensure we only pass in those args that are expected by this
            # implementation. This is important for SWIG'ified classes, such as
            # TemporalMemoryCPP, which don't take kwargs.
            expectedArgs = getConstructorArguments(self.temporalImp)[0]
            for arg in args.keys():
                if not arg in expectedArgs:
                    args.pop(arg)

            # Create the TM instance.
            self._tm = createModel(self.implementation, **args)

            # Carry some information to the next time step.
            self.prevPredictiveCells = ()
            self.prevActiveExternalCells = ()
            self.prevActiveApicalCells = ()
Example #4
0
  def initialize(self, inputs, outputs):
    """
    Initialize the self._tm if not already initialized. We need to figure out
    the constructor parameters for each class, and send it to that constructor.
    """
    if self._tm is None:
      # Create dict of arguments we will pass to the temporal memory class
      args = copy.deepcopy(self.__dict__)
      args["columnDimensions"] = (self.columnCount,)

      # Ensure we only pass in those args that are expected by this
      # implementation. This is important for SWIG'ified classes, such as
      # TemporalMemoryCPP, which don't take kwargs.
      expectedArgs = getConstructorArguments(self.temporalImp)[0]
      for arg in args.keys():
        if not arg in expectedArgs:
          args.pop(arg)

      # Create the TM instance
      self._tm = createModel(self.temporalImp, **args)

      # numpy arrays we will use for some of the outputs
      self.activeState = numpy.zeros(self._tm.numberOfCells())
      self.previouslyPredictedCells = numpy.zeros(self._tm.numberOfCells())