tm = TM(columnDimensions = (50,),
        cellsPerColumn=2,
        initialPermanence=0.5,
        connectedPermanence=0.5,
        minThreshold=8,
        maxNewSynapseCount=20,
        permanenceIncrement=0.1,
        permanenceDecrement=0.0,
        activationThreshold=8,
        )


# Step 2: create input vectors to feed to the temporal memory. Each input vector
# must be numberOfCols wide. Here we create a simple sequence of 5 vectors
# representing the sequence A -> B -> C -> D -> E
x = np.zeros((5, tm.numberOfColumns()), dtype="uint32")
x[0, 0:10] = 1    # Input SDR representing "A", corresponding to columns 0-9
x[1, 10:20] = 1   # Input SDR representing "B", corresponding to columns 10-19
x[2, 20:30] = 1   # Input SDR representing "C", corresponding to columns 20-29
x[3, 30:40] = 1   # Input SDR representing "D", corresponding to columns 30-39
x[4, 40:50] = 1   # Input SDR representing "E", corresponding to columns 40-49


# Step 3: send this simple sequence to the temporal memory for learning
# We repeat the sequence 10 times
for i in range(10):

  # Send each letter in the sequence in order
  for j in range(5):
    activeColumns = set([i for i, j in zip(count(), x[j]) if j == 1])
Example #2
0
tm = TM(
    columnDimensions=(50, ),
    cellsPerColumn=2,
    initialPermanence=0.5,
    connectedPermanence=0.5,
    minThreshold=8,
    maxNewSynapseCount=20,
    permanenceIncrement=0.1,
    permanenceDecrement=0.0,
    activationThreshold=8,
)

# Step 2: create input vectors to feed to the temporal memory. Each input vector
# must be numberOfCols wide. Here we create a simple sequence of 5 vectors
# representing the sequence A -> B -> C -> D -> E
x = numpy.zeros((5, tm.numberOfColumns()), dtype="uint32")
x[0, 0:10] = 1  # Input SDR representing "A", corresponding to columns 0-9
x[1, 10:20] = 1  # Input SDR representing "B", corresponding to columns 10-19
x[2, 20:30] = 1  # Input SDR representing "C", corresponding to columns 20-29
x[3, 30:40] = 1  # Input SDR representing "D", corresponding to columns 30-39
x[4, 40:50] = 1  # Input SDR representing "E", corresponding to columns 40-49

# Step 3: send this simple sequence to the temporal memory for learning
# We repeat the sequence 10 times
for i in range(10):

    # Send each letter in the sequence in order
    for j in range(5):
        activeColumns = set([i for i, j in zip(count(), x[j]) if j == 1])

        # The compute method performs one step of learning and/or inference. Note:
Example #3
0
tm = TM(columnDimensions = (50,),
        cellsPerColumn=2,
        initialPermanence=0.5,
        connectedPermanence=0.5,
        minThreshold=8,
        maxNewSynapseCount=20,
        permanenceIncrement=0.1,
        permanenceDecrement=0.0,
        activationThreshold=8,
        )


# Step 2: create input vectors to feed to the temporal memory. Each input vector
# must be numberOfCols wide. Here we create a simple sequence of 5 vectors
# representing the sequence A -> B -> C -> D -> E
x = numpy.zeros((5, tm.numberOfColumns()), dtype="uint32")
x[0, 0:10] = 1    # Input SDR representing "A", corresponding to columns 0-9
x[1, 10:20] = 1   # Input SDR representing "B", corresponding to columns 10-19
x[2, 20:30] = 1   # Input SDR representing "C", corresponding to columns 20-29
x[3, 30:40] = 1   # Input SDR representing "D", corresponding to columns 30-39
x[4, 40:50] = 1   # Input SDR representing "E", corresponding to columns 40-49


# Step 3: send this simple sequence to the temporal memory for learning
# We repeat the sequence 10 times
for i in range(10):

  # Send each letter in the sequence in order
  for j in range(5):
    activeColumns = set([i for i, j in zip(count(), x[j]) if j == 1])
Example #4
0
 def testNumberOfColumns(self):
   tm = TemporalMemory(
     columnDimensions=[64, 64],
     cellsPerColumn=32
   )
   self.assertEqual(tm.numberOfColumns(), 64 * 64)
Example #5
0
GPIO.setmode(GPIO.BCM)
mode = 0

tm = TemporalMemory(
    columnDimensions=(200, ),
    cellsPerColumn=32,
    initialPermanence=0.5,
    connectedPermanence=0.5,
    minThreshold=10,
    maxNewSynapseCount=32,
    permanenceIncrement=0.1,
    permanenceDecrement=0.1,
    activationThreshold=13,
)

inputSDRs = numpy.zeros((5, tm.numberOfColumns()), dtype="uint32")
for x in range(5):
    inputSDRs[x, (x * 40):((x + 1) * 40)] = 1

inputColumns = []
for x in range(5):
    inputColumns.append(set([c for c, i in enumerate(inputSDRs[x]) if i == 1]))

ledPins = [26, 19, 17, 27, 22]
leds = []
for x in range(5):
    leds.append(Led(ledPins[x]))

tones = [0, 220, 262, 330, 440]
speaker = Speaker(13)
 def testNumberOfColumns(self):
   tm = TemporalMemory(
     columnDimensions=[64, 64],
     cellsPerColumn=32
   )
   self.assertEqual(tm.numberOfColumns(), 64 * 64)