コード例 #1
0
ファイル: connections_test.py プロジェクト: Erichy94/nupic
  def testComputeActivity(self):
    """ Creates a sample set of connections, and makes sure that computing the
        activity for a collection of cells with no activity returns the right
        activity data.
    """
    connections = Connections(1024)

    # Cell with 1 segment.
    # Segment with:
    # - 1 connected synapse: active
    # - 2 matching synapses
    segment1a = connections.createSegment(10)
    connections.createSynapse(segment1a, 150, .85)
    connections.createSynapse(segment1a, 151, .15)

    # Cell with 1 segment.
    # Segment with:
    # - 2 connected synapse: 2 active
    # - 3 matching synapses: 3 active
    segment2a = connections.createSegment(20)
    connections.createSynapse(segment2a, 80, .85)
    connections.createSynapse(segment2a, 81, .85)
    synapse = connections.createSynapse(segment2a, 82, .85)
    connections.updateSynapsePermanence(synapse, .15)

    inputVec = [50, 52, 53, 80, 81, 82, 150, 151]
    (numActiveConnected,
     numActivePotential) = connections.computeActivity(inputVec, .5)

    self.assertEqual(1, numActiveConnected[segment1a.flatIdx])
    self.assertEqual(2, numActivePotential[segment1a.flatIdx])

    self.assertEqual(2, numActiveConnected[segment2a.flatIdx])
    self.assertEqual(3, numActivePotential[segment2a.flatIdx])
コード例 #2
0
ファイル: connections_test.py プロジェクト: hoploop/nupic3
    def testComputeActivity(self):
        """ Creates a sample set of connections, and makes sure that computing the
        activity for a collection of cells with no activity returns the right
        activity data.
    """
        connections = Connections(1024)

        # Cell with 1 segment.
        # Segment with:
        # - 1 connected synapse: active
        # - 2 matching synapses
        segment1a = connections.createSegment(10)
        connections.createSynapse(segment1a, 150, .85)
        connections.createSynapse(segment1a, 151, .15)

        # Cell with 1 segment.
        # Segment with:
        # - 2 connected synapse: 2 active
        # - 3 matching synapses: 3 active
        segment2a = connections.createSegment(20)
        connections.createSynapse(segment2a, 80, .85)
        connections.createSynapse(segment2a, 81, .85)
        synapse = connections.createSynapse(segment2a, 82, .85)
        connections.updateSynapsePermanence(synapse, .15)

        inputVec = [50, 52, 53, 80, 81, 82, 150, 151]
        (numActiveConnected,
         numActivePotential) = connections.computeActivity(inputVec, .5)

        self.assertEqual(1, numActiveConnected[segment1a.flatIdx])
        self.assertEqual(2, numActivePotential[segment1a.flatIdx])

        self.assertEqual(2, numActiveConnected[segment2a.flatIdx])
        self.assertEqual(3, numActivePotential[segment2a.flatIdx])
コード例 #3
0
ファイル: connections_test.py プロジェクト: Erichy94/nupic
  def testUpdateSynapsePermanence(self):
    """ Creates a synapse and updates its permanence, and makes sure that its
        data was correctly updated.
    """
    connections = Connections(1024)
    segment = connections.createSegment(10)
    synapse = connections.createSynapse(segment, 50, .34)

    connections.updateSynapsePermanence(synapse, .21)

    synapseData = connections.dataForSynapse(synapse)
    self.assertAlmostEqual(synapseData.permanence, .21)
コード例 #4
0
ファイル: connections_test.py プロジェクト: hoploop/nupic3
    def testUpdateSynapsePermanence(self):
        """ Creates a synapse and updates its permanence, and makes sure that its
        data was correctly updated.
    """
        connections = Connections(1024)
        segment = connections.createSegment(10)
        synapse = connections.createSynapse(segment, 50, .34)

        connections.updateSynapsePermanence(synapse, .21)

        synapseData = connections.dataForSynapse(synapse)
        self.assertAlmostEqual(synapseData.permanence, .21)