Пример #1
0
    def testBestMatchingCell(self):
        tm = TemporalMemory(connectedPermanence=0.50, minThreshold=1, seed=42)

        connections = tm.connections
        connections.createSegment(0)
        connections.createSynapse(0, 23, 0.6)
        connections.createSynapse(0, 37, 0.4)
        connections.createSynapse(0, 477, 0.9)

        connections.createSegment(0)
        connections.createSynapse(1, 49, 0.9)
        connections.createSynapse(1, 3, 0.8)

        connections.createSegment(1)
        connections.createSynapse(2, 733, 0.7)

        connections.createSegment(108)
        connections.createSynapse(3, 486, 0.9)

        activeCells = set([23, 37, 49, 733])

        self.assertEqual(
            tm.bestMatchingCell(tm.cellsForColumn(0), activeCells), (0, 0))

        self.assertEqual(
            tm.bestMatchingCell(
                tm.cellsForColumn(3),  # column containing cell 108
                activeCells),
            (103, None))  # Random cell from column

        self.assertEqual(
            tm.bestMatchingCell(tm.cellsForColumn(999), activeCells),
            (31979, None))  # Random cell from column
Пример #2
0
  def testBestMatchingCell(self):
    tm = TemporalMemory(
      connectedPermanence=0.50,
      minThreshold=1,
      seed=42
    )

    connections = tm.connections
    connections.createSegment(0)
    connections.createSynapse(0, 23, 0.6)
    connections.createSynapse(0, 37, 0.4)
    connections.createSynapse(0, 477, 0.9)

    connections.createSegment(0)
    connections.createSynapse(1, 49, 0.9)
    connections.createSynapse(1, 3, 0.8)

    connections.createSegment(1)
    connections.createSynapse(2, 733, 0.7)

    connections.createSegment(108)
    connections.createSynapse(3, 486, 0.9)

    activeCells = set([23, 37, 49, 733])

    self.assertEqual(tm.bestMatchingCell(tm.cellsForColumn(0),
                                         activeCells,
                                         connections),
                     (0, 0))

    self.assertEqual(tm.bestMatchingCell(tm.cellsForColumn(3),  # column containing cell 108
                                         activeCells,
                                         connections),
                     (96, None))  # Random cell from column

    self.assertEqual(tm.bestMatchingCell(tm.cellsForColumn(999),
                                         activeCells,
                                         connections),
                     (31972, None))  # Random cell from column
Пример #3
0
    def testBestMatchingCellFewestSegments(self):
        tm = TemporalMemory(columnDimensions=[2],
                            cellsPerColumn=2,
                            connectedPermanence=0.50,
                            minThreshold=1,
                            seed=42)

        connections = tm.connections
        connections.createSegment(0)
        connections.createSynapse(0, 3, 0.3)

        activeSynapsesForSegment = set([])

        for _ in range(100):
            # Never pick cell 0, always pick cell 1
            (cell, _) = tm.bestMatchingCell(tm.cellsForColumn(0),
                                            activeSynapsesForSegment)
            self.assertEqual(cell, 1)
Пример #4
0
  def testBestMatchingCellFewestSegments(self):
    tm = TemporalMemory(
      columnDimensions=[2],
      cellsPerColumn=2,
      connectedPermanence=0.50,
      minThreshold=1,
      seed=42
    )

    connections = tm.connections
    connections.createSegment(0)
    connections.createSynapse(0, 3, 0.3)

    activeSynapsesForSegment = set([])

    for _ in range(100):
      # Never pick cell 0, always pick cell 1
      (cell, _) = tm.bestMatchingCell(tm.cellsForColumn(0),
                                      activeSynapsesForSegment)
      self.assertEqual(cell, 1)