Exemplo n.º 1
0
  connectedPermanence=0.3,
  minThreshold=15,
  maxNewSynapseCount=40,
  permanenceIncrement=0.1,
  permanenceDecrement=0.1,
  activationThreshold=15,
  predictedSegmentDecrement=0.01,
  )
tm.printParameters()

print("""
We will create a sparse representation of characters A, B, C, D, X, and Y.
In this particular example we manually construct them, but usually you would
use the spatial pooler to build these.""")
sparsity   = 0.02
sparseCols = int(tm.numberOfColumns() * sparsity)
dataset    = {inp : SDR( tm.numberOfColumns() ) for inp in "ABCDXY"}
for i, inp in enumerate("ABCDXY"):
  dataset[inp].dense[ i * sparseCols : (i + 1) * sparseCols ] = 1
  dataset[inp].dense = dataset[inp].dense # This line notifies the SDR that it's dense data has changed in-place.
  print("Input", inp, "is bits at indices: [",  i * sparseCols, '-', (i + 1) * sparseCols, ')')

seq1 = "ABCD"
seq2 = "XBCY"
seqT = "ABCDXY"


def trainTM(sequence, iterations, noiseLevel):
  """
  Trains the TM with given sequence for a given number of time steps and level
  of input corruption
Exemplo n.º 2
0
    cellsPerColumn=1,
    initialPermanence=0.5,
    connectedPermanence=0.5,
    minThreshold=8,
    maxNewSynapseCount=20,
    permanenceIncrement=0.1,
    permanenceDecrement=0.0,
    activationThreshold=8,
)
tm.printParameters()

print("""
Creating inputs to feed to the temporal memory. Each input is an SDR
representing the active mini-columns.  Here we create a simple sequence of 5
SDRs representing the sequence A -> B -> C -> D -> E """)
dataset = {inp: SDR(tm.numberOfColumns()) for inp in "ABCDE"}
dataset['A'].dense[
    0:10] = 1  # Input SDR representing "A", corresponding to mini-columns 0-9
dataset['B'].dense[
    10:
    20] = 1  # Input SDR representing "B", corresponding to mini-columns 10-19
dataset['C'].dense[
    20:
    30] = 1  # Input SDR representing "C", corresponding to mini-columns 20-29
dataset['D'].dense[
    30:
    40] = 1  # Input SDR representing "D", corresponding to mini-columns 30-39
dataset['E'].dense[
    40:
    50] = 1  # Input SDR representing "E", corresponding to mini-columns 40-49
# Notify the SDR object that we've updated its dense data in-place.