Example #1
0
 def testPatternTraining(self):
     'test that within columns, particular cells dominate when they recognize learned temporal patterns'
     htm = self.htm
     
     #2d format, same dimensions as htm (for now)
     data = [
         [1,0,1,0,1,0,1,0,1,0],
         [0,0,0,0,1,0,1,0,1,1],
         [0,0,1,0,1,0,0,0,0,1],
         [0,1,0,0,1,1,0,1,0,1],
         [1,0,1,0,1,0,1,0,0,1],
         [0,0,0,1,1,0,0,0,1,1],
         ]
     
     htm.initialize_input(data)
                 
     flipDat = flipDataGenerator(htm)
     htm.execute(data, flipDat, ticks=100)
     
     htm.execute(data, flipDat, ticks=1)
     
     activeCols = htm.columns_active()
     
     #all columns should have learned particular cell patterns by now
     for col in activeCols:
         self.assertNotEqual(len(col.cells), len(filter(lambda cell: cell.active, col.cells)))
Example #2
0
 def testDataLoop(self):
     htm = self.htm
     data = [[1,0,1],[0,0,1]] #2d format, same dimensions as htm (for now)
 
     htm.initialize_input(data)
                 
     htm.execute(data, flipDataGenerator(htm), ticks=20)
Example #3
0
 def testStability(self):
     'test that repeated patterns get recognized by the same columns after stabilizing'
     htm = self.htm
     
     #2d format, same dimensions as htm (for now)
     data = [[1,0,1,0,1,0,1,0,1,0],[0,0,0,0,1,0,0,0,0,1]]
     
     htm.initialize_input(data)
                 
     flipDat = flipDataGenerator(htm)
     htm.execute(data, flipDat, ticks=50)
     active = htm.columns_active()
     htm.execute(data, flipDat, ticks=2)
     self.assertEqual(active, htm.columns_active())
     htm.execute(data, flipDat, ticks=2)
     self.assertEqual(active, htm.columns_active())
     
     #show that stability is non-trivial because it changes at the next time step
     htm.execute(data, flipDat)
     self.assertNotEqual(active, htm.columns_active())