def testCellsForColumnInvalidColumn(self):
    connections = Connections([64, 64], 4)

    try:
      connections.cellsForColumn(4095)
    except IndexError:
      self.fail("IndexError raised unexpectedly")

    args = [4096]
    self.assertRaises(IndexError, connections.cellsForColumn, *args)

    args = [-1]
    self.assertRaises(IndexError, connections.cellsForColumn, *args)
  def testColumnForCellInvalidCell(self):
    connections = Connections([64, 64], 4)

    try:
      connections.columnForCell(16383)
    except IndexError:
      self.fail("IndexError raised unexpectedly")

    args = [16384]
    self.assertRaises(IndexError, connections.columnForCell, *args)

    args = [-1]
    self.assertRaises(IndexError, connections.columnForCell, *args)
  def testInit(self):
    columnDimensions = [2048]
    cellsPerColumn = 32

    connections = Connections(columnDimensions, cellsPerColumn)
    self.assertEqual(connections.columnDimensions, columnDimensions)
    self.assertEqual(connections.cellsPerColumn, cellsPerColumn)
    def __init__(self,
                 columnDimensions=(2048, ),
                 cellsPerColumn=32,
                 activationThreshold=13,
                 learningRadius=2048,
                 initialPermanence=0.21,
                 connectedPermanence=0.50,
                 minThreshold=10,
                 maxNewSynapseCount=20,
                 permanenceIncrement=0.10,
                 permanenceDecrement=0.10,
                 seed=42):
        """
    Translate parameters and initialize member variables
    specific to TemporalMemory
    """
        numberOfCols = 1
        for n in columnDimensions:
            numberOfCols *= n

        super(TemporalMemoryShim,
              self).__init__(numberOfCols=numberOfCols,
                             cellsPerColumn=cellsPerColumn,
                             initialPerm=initialPermanence,
                             connectedPerm=connectedPermanence,
                             minThreshold=minThreshold,
                             newSynapseCount=maxNewSynapseCount,
                             permanenceInc=permanenceIncrement,
                             permanenceDec=permanenceDecrement,
                             permanenceMax=1.0,
                             globalDecay=0,
                             activationThreshold=activationThreshold,
                             seed=seed)

        self.connections = Connections(columnDimensions, cellsPerColumn)
        self.predictiveCells = set()
 def testNumberOfCells(self):
   connections = Connections([64, 64], 32)
   self.assertEqual(connections.numberOfCells(), 64 * 64 * 32)
 def testCellsForColumn2D(self):
   connections = Connections([64, 64], 4)
   expectedCells = set([256, 257, 258, 259])
   self.assertEqual(connections.cellsForColumn(64), expectedCells)
 def testCellsForColumn1D(self):
   connections = Connections([2048], 5)
   expectedCells = set([5, 6, 7, 8, 9])
   self.assertEqual(connections.cellsForColumn(1), expectedCells)
 def testColumnForCell2D(self):
   connections = Connections([64, 64], 4)
   self.assertEqual(connections.columnForCell(0), 0)
   self.assertEqual(connections.columnForCell(3), 0)
   self.assertEqual(connections.columnForCell(4), 1)
   self.assertEqual(connections.columnForCell(16383), 4095)
 def testColumnForCell1D(self):
   connections = Connections([2048], 5)
   self.assertEqual(connections.columnForCell(0), 0)
   self.assertEqual(connections.columnForCell(4), 0)
   self.assertEqual(connections.columnForCell(5), 1)
   self.assertEqual(connections.columnForCell(10239), 2047)
 def setUp(self):
   self.connections = Connections([2048], 32)
Beispiel #11
0
 def testMapCellsToColumns(self):
   connections = Connections([100], 4)
   columnsForCells = connections.mapCellsToColumns(set([0, 1, 2, 5, 399]))
   self.assertEqual(columnsForCells[0], set([0, 1, 2]))
   self.assertEqual(columnsForCells[1], set([5]))
   self.assertEqual(columnsForCells[99], set([399]))
 def setUp(self):
     self.connections = Connections(2048 * 32)
Beispiel #13
0
 def testMapCellsToColumns(self):
     connections = Connections([100], 4)
     columnsForCells = connections.mapCellsToColumns(set([0, 1, 2, 5, 399]))
     self.assertEqual(columnsForCells[0], set([0, 1, 2]))
     self.assertEqual(columnsForCells[1], set([5]))
     self.assertEqual(columnsForCells[99], set([399]))