def trainWithSpecificPairSDRs(self, pairLayerContexts):
    """
    Train the pair layer and pooling layer, manually choosing which contexts
    each cell will encode (i.e. the pair layer's distal connections).

    @param pairLayerContexts (list of lists of lists of ints)
    iContext integers for each cell, grouped by minicolumn. For example,
      [[[1, 3], [2,4]],
       [[1, 2]]]
    would specify that cell 0 connects to location 1 and location 3, while cell
    1 connects to locations 2 and 4, and cell 2 (in the second minicolumn)
    connects to locations 1 and 2.
    """
    # Grow basal segments in the pair layer.
    for iMinicolumn, contextsByCell in enumerate(pairLayerContexts):
      for iCell, cellContexts in enumerate(contextsByCell):
        iCellAbsolute = iMinicolumn*self.pairLayer.getCellsPerColumn() + iCell
        for context in cellContexts:
          segments = self.pairLayer.basalConnections.createSegments(
            [iCellAbsolute])
          self.pairLayer.basalConnections.growSynapses(
            segments, self.contextOperandSDRs[context], 1.0)

    # Associate the pair layer's minicolumn SDRs with offset cell SDRs,
    # and associate the pooling layer's location SDRs with a pool of pair SDRs.
    for iDriving, cDriving in enumerate(self.drivingOperandSDRs):
      minicolumnSDR = self.minicolumnSDRs[iDriving]
      self.pairLayerProximalConnections.associate(minicolumnSDR, cDriving)

      for iContext, cContext in enumerate(self.contextOperandSDRs):
        iResult = (iContext + iDriving) % self.numLocations
        cResult = self.resultSDRs[iResult]
        cPair = [
          iMinicolumn*self.pairLayer.getCellsPerColumn() + iCell
          for iMinicolumn in minicolumnSDR
          for iCell, cellContexts in enumerate(pairLayerContexts[iMinicolumn])
          if iContext in cellContexts]
        assert len(cPair) == len(minicolumnSDR)

        self.poolingLayer.associate(cResult, cPair)
def trainWithSpecificPairSDRs ( self , pairLayerContexts ) : for iMinicolumn , contextsByCell in enumerate ( pairLayerContexts ) : for iCell , cellContexts in enumerate ( contextsByCell ) : iCellAbsolute = iMinicolumn * self . pairLayer . getCellsPerColumn ( ) + iCell for context in cellContexts : segments = self . pairLayer . basalConnections . createSegments ( [ iCellAbsolute ] ) self . pairLayer . basalConnections . growSynapses ( segments , self . contextOperandSDRs [ context ] , 1.0 ) for iDriving , cDriving in enumerate ( self . drivingOperandSDRs ) : minicolumnSDR = self . minicolumnSDRs [ iDriving ] self . pairLayerProximalConnections . associate ( minicolumnSDR , cDriving ) for iContext , cContext in enumerate ( self . contextOperandSDRs ) : iResult = ( iContext + iDriving ) % self . numLocations cResult = self . resultSDRs [ iResult ] cPair = [ iMinicolumn * self . pairLayer . getCellsPerColumn ( ) + iCell for iMinicolumn in minicolumnSDR for iCell , cellContexts in enumerate ( pairLayerContexts [ iMinicolumn ] ) if iContext in cellContexts ] assert len ( cPair ) == len ( minicolumnSDR ) self . poolingLayer . associate ( cResult , cPair )
Train the pair layer and pooling layer, manually choosing which contexts
    each cell will encode (i.e. the pair layer's distal connections).

    @param pairLayerContexts (list of lists of lists of ints)
    iContext integers for each cell, grouped by minicolumn. For example,
      [[[1, 3], [2,4]],
       [[1, 2]]]
    would specify that cell 0 connects to location 1 and location 3, while cell
    1 connects to locations 2 and 4, and cell 2 (in the second minicolumn)
    connects to locations 1 and 2.