def buildOverlappedSequences(numSequences=2, seqLen=5, sharedElements=[3, 4], numOnBitsPerPattern=3, patternOverlap=0, seqOverlap=0, **kwargs):
 numSharedElements = len(sharedElements)
 numUniqueElements = (seqLen - numSharedElements)
 numPatterns = (numSharedElements + (numUniqueElements * numSequences))
 patterns = getSimplePatterns(numOnBitsPerPattern, numPatterns, patternOverlap)
 numCols = len(patterns[0])
 trainingSequences = []
 uniquePatternIndices = range(numSharedElements, numPatterns)
 for _ in xrange(numSequences):
  sequence = []
  sharedPatternIndices = range(numSharedElements)
  for j in xrange(seqLen):
   if (j in sharedElements):
    patIdx = sharedPatternIndices.pop(0)
   else:
    patIdx = uniquePatternIndices.pop(0)
   sequence.append(patterns[patIdx])
  trainingSequences.append(sequence)
 if (VERBOSITY >= 3):
  print '\nTraining sequences'
  printAllTrainingSequences(trainingSequences)
 return (numCols, trainingSequences)

def buildOverlappedSequences ( numSequences = 2 , seqLen = 5 , sharedElements = [ 3 , 4 ] , numOnBitsPerPattern = 3 , patternOverlap = 0 , seqOverlap = 0 , ** kwargs ) : numSharedElements = len ( sharedElements ) numUniqueElements = ( seqLen - numSharedElements ) numPatterns = ( numSharedElements + ( numUniqueElements * numSequences ) ) patterns = getSimplePatterns ( numOnBitsPerPattern , numPatterns , patternOverlap ) numCols = len ( patterns [ 0 ] ) trainingSequences = [ ] uniquePatternIndices = range ( numSharedElements , numPatterns ) for _ in xrange ( numSequences ) : sequence = [ ] sharedPatternIndices = range ( numSharedElements ) for j in xrange ( seqLen ) : if ( j in sharedElements ) : patIdx = sharedPatternIndices . pop ( 0 ) else : patIdx = uniquePatternIndices . pop ( 0 ) sequence . append ( patterns [ patIdx ] ) trainingSequences . append ( sequence ) if ( VERBOSITY >= 3 ) : print '\nTraining sequences' printAllTrainingSequences ( trainingSequences ) return ( numCols , trainingSequences )
create training sequences that share some elements in the middle .