Esempio n. 1
0
  def _allocateSpatialFDR(self, rfInput):
    """Allocate the spatial pooler instance."""
    if self._sfdr:
      return

    # Retrieve the necessary extra arguments that were handled automatically
    autoArgs = dict((name, getattr(self, name))
                     for name in self._spatialArgNames)
    
    # Instantiate the spatial pooler class.
    if ( (self._FDRCSpatialClass == CPPSpatialPooler) or
         (self._FDRCSpatialClass == PYSpatialPooler) ):
      
      autoArgs['columnDimensions'] = [self.columnCount]
      autoArgs['inputDimensions'] = [self.inputWidth]
      autoArgs['potentialRadius'] = self.inputWidth
    
      self._sfdr = self._FDRCSpatialClass(
        **autoArgs
      )
      
    else:
      # Backward compatibility
      autoArgs.pop('coincidencesShape')
      autoArgs.pop('inputShape')
      autoArgs.pop('inputBorder')
      autoArgs.pop('coincInputRadius')
      autoArgs.pop('cloneMap')
      autoArgs.pop('numCloneMasters')
  
      coincidencesShape = (self.columnCount, 1)
      inputShape = (1, self.inputWidth)
      inputBorder = inputShape[1]/2
      if inputBorder*2 >= inputShape[1]:
        inputBorder -= 1
      coincInputRadius = inputShape[1]/2
  
      cloneMap, numCloneMasters = fdru.makeCloneMap(
          columnsShape=coincidencesShape,
          outputCloningWidth=coincidencesShape[1],
          outputCloningHeight=coincidencesShape[0]
        )
  
      self._sfdr = self._FDRCSpatialClass(
                                # These parameters are standard defaults for SPRegion
                                # They can be overridden by explicit calls to
                                # getParameter
                                cloneMap=cloneMap,
                                numCloneMasters=numCloneMasters,
                                coincidencesShape=coincidencesShape,
                                inputShape=inputShape,
                                inputBorder=inputBorder,
                                coincInputRadius = coincInputRadius,
                                **autoArgs)
Esempio n. 2
0
    def _allocateSpatialFDR(self, rfInput):
        """Allocate the spatial pooler instance."""
        if self._sfdr:
            return

        # Retrieve the necessary extra arguments that were handled automatically
        autoArgs = dict(
            (name, getattr(self, name)) for name in self._spatialArgNames)

        # Instantiate the spatial pooler class.
        if ((self._FDRCSpatialClass == CPPSpatialPooler)
                or (self._FDRCSpatialClass == PYSpatialPooler)):

            autoArgs['columnDimensions'] = [self.columnCount]
            autoArgs['inputDimensions'] = [self.inputWidth]
            autoArgs['potentialRadius'] = self.inputWidth

            self._sfdr = self._FDRCSpatialClass(**autoArgs)

        else:
            # Backward compatibility
            autoArgs.pop('coincidencesShape')
            autoArgs.pop('inputShape')
            autoArgs.pop('inputBorder')
            autoArgs.pop('coincInputRadius')
            autoArgs.pop('cloneMap')
            autoArgs.pop('numCloneMasters')

            coincidencesShape = (self.columnCount, 1)
            inputShape = (1, self.inputWidth)
            inputBorder = inputShape[1] / 2
            if inputBorder * 2 >= inputShape[1]:
                inputBorder -= 1
            coincInputRadius = inputShape[1] / 2

            cloneMap, numCloneMasters = fdru.makeCloneMap(
                columnsShape=coincidencesShape,
                outputCloningWidth=coincidencesShape[1],
                outputCloningHeight=coincidencesShape[0])

            self._sfdr = self._FDRCSpatialClass(
                # These parameters are standard defaults for SPRegion
                # They can be overridden by explicit calls to
                # getParameter
                cloneMap=cloneMap,
                numCloneMasters=numCloneMasters,
                coincidencesShape=coincidencesShape,
                inputShape=inputShape,
                inputBorder=inputBorder,
                coincInputRadius=coincInputRadius,
                **autoArgs)
Esempio n. 3
0
  def _allocateSpatialFDR(self, rfInput):
    """Allocate the spatial pooler instance."""
    if self._sfdr:
      return

    # Retrieve the necessary extra arguments that were handled automatically
    autoArgs = dict((name, getattr(self, name))
                     for name in self._spatialArgNames)
    autoArgs.pop('coincidencesShape')
    autoArgs.pop('inputShape')
    autoArgs.pop('inputBorder')
    autoArgs.pop('coincInputRadius')
    autoArgs.pop('cloneMap')
    autoArgs.pop('numCloneMasters')

    coincidencesShape = (self.columnCount, 1)
    inputShape = (1, self.inputWidth)
    inputBorder = inputShape[1]/2
    if inputBorder*2 >= inputShape[1]:
      inputBorder -= 1
    coincInputRadius = inputShape[1]/2

    cloneMap, numCloneMasters = fdru.makeCloneMap(
        columnsShape=coincidencesShape,
        outputCloningWidth=coincidencesShape[1],
        outputCloningHeight=coincidencesShape[0]
      )

    self._sfdr = FDRCSpatial2.FDRCSpatial2(
                              # These parameters are standard defaults for SPRegion
                              # They can be overridden by explicit calls to
                              # getParameter
                              cloneMap=cloneMap,
                              numCloneMasters=numCloneMasters,
                              coincidencesShape=coincidencesShape,
                              inputShape=inputShape,
                              inputBorder=inputBorder,
                              coincInputRadius = coincInputRadius,
                              **autoArgs)

    self._sfdr.setStoreDenseOutput(self.storeDenseOutput)