Example #1
0
    def __init__(
            self,
            inputDimensions=[32, 32],
            columnDimensions=[64, 64],
            potentialRadius=16,
            potentialPct=0.9,
            globalInhibition=True,
            localAreaDensity=-1.0,
            numActiveColumnsPerInhArea=20.0,
            stimulusThreshold=2,
            synPermInactiveDec=0.01,
            synPermActiveInc=0.03,
            synPermConnected=0.3,
            minPctOverlapDutyCycle=0.001,
            minPctActiveDutyCycle=0.001,
            dutyCyclePeriod=1000,
            maxBoost=1.0,
            seed=42,
            spVerbosity=0,
            wrapAround=True,

            # union_pooler.py parameters
            activeOverlapWeight=1.0,
            predictedActiveOverlapWeight=0.0,
            fixedPoolingActivationBurst=False,
            exciteFunction=None,
            decayFunction=None,
            maxUnionActivity=0.20):
        """
    Please see spatial_pooler.py in NuPIC for super class parameter
    descriptions.

    Class-specific parameters:
    -------------------------------------

    @param activeOverlapWeight: A multiplicative weight applied to
        the overlap between connected synapses and active-cell input

    @param predictedActiveOverlapWeight: A multiplicative weight applied to
        the overlap between connected synapses and predicted-active-cell input

    @param fixedPoolingActivationBurst: A Boolean, which, if True, has the
        Union Pooler grant a fixed amount of pooling activation to
        columns whenever they win the inhibition step. If False, columns'
        pooling activation is calculated based on their current overlap.

    @param exciteFunction: If fixedPoolingActivationBurst is False,
        this specifies the ExciteFunctionBase used to excite pooling
        activation.

    @param decayFunction: Specifies the DecayFunctionBase used to decay pooling
        activation.

    @param maxUnionActivity: Maximum number of active cells allowed in union SDR
        simultaneously in terms of the ratio between the number of active cells
        and the number of total cells
    """

        super(UnionPooler, self).__init__(
            inputDimensions, columnDimensions, potentialRadius, potentialPct,
            globalInhibition, localAreaDensity, numActiveColumnsPerInhArea,
            stimulusThreshold, synPermInactiveDec, synPermActiveInc,
            synPermConnected, minPctOverlapDutyCycle, minPctActiveDutyCycle,
            dutyCyclePeriod, maxBoost, seed, spVerbosity, wrapAround)

        self._activeOverlapWeight = activeOverlapWeight
        self._predictedActiveOverlapWeight = predictedActiveOverlapWeight
        self._fixedPoolingActivationBurst = fixedPoolingActivationBurst
        self._maxUnionActivity = maxUnionActivity

        if exciteFunction is None:
            self._exciteFunction = LinearExciteFunction()
        else:
            self._exciteFunction = exciteFunction

        if decayFunction is None:
            self._decayFunction = NoDecayFunction()
        else:
            self._decayFunction = decayFunction

        # The maximum number of cells allowed in a single union SDR
        self._maxUnionCells = int(self._numColumns * self._maxUnionActivity)

        # Scalar activation of potential union SDR cells; most active cells become
        # the union SDR
        self._poolingActivation = numpy.zeros(self._numColumns,
                                              dtype=REAL_DTYPE)

        # Current union SDR; the end product of the union pooler algorithm
        self._unionSDR = numpy.array([], dtype=INT_DTYPE)