コード例 #1
0
    def test_adjustSynapses(self):
        for (name, cells, inputs, adjustedSegments, activeInputs,
             initialPermanence, activeDelta, inactiveDelta,
             connectedPermanence,
             expected) in (("Basic test", [1, 2, 3], [42, 43, 44], [0, 2],
                            [42, 44], 0.45, 0.1, -0.1, 0.5, [2, 0, 2]),
                           ("Reward inactive", [1, 2, 3], [42, 43, 44], [0, 2],
                            [42, 44], 0.45, -0.1, 0.1, 0.5, [1, 0, 1]),
                           ("No segments", [1, 2, 3], [42, 43, 44], [],
                            [42, 44], 0.45, 0.1, -0.1, 0.5, [0, 0, 0]),
                           ("No active synapses", [1, 2, 3], [42, 43, 44],
                            [0, 2], [], 0.45, 0.1, -0.1, 0.5, [0, 0, 0]),
                           ("Delta of zero", [1, 2, 3], [42, 43, 44], [0, 2],
                            [42, 44], 0.55, 0.0, 0.0, 0.5, [3, 3, 3])):

            connections = SparseMatrixConnections(2048, 2048)

            segments = connections.createSegments(cells)

            connections.growSynapses(segments, inputs, initialPermanence)
            connections.adjustSynapses(segments[adjustedSegments],
                                       activeInputs, activeDelta,
                                       inactiveDelta)

            overlaps = connections.computeActivity(inputs, connectedPermanence)

            np.testing.assert_equal(overlaps[segments], expected, name)
コード例 #2
0
ファイル: connections_test.py プロジェクト: EricSB/nupic.core
  def test_adjustSynapses(self):
    for (name, cells, inputs,
         adjustedSegments, activeInputs,
         initialPermanence, activeDelta, inactiveDelta, connectedPermanence,
         expected) in (("Basic test",
                        [1, 2, 3], [42, 43, 44],
                        [0, 2], [42, 44],
                        0.45, 0.1, -0.1, 0.5,
                        [2, 0, 2]),
                       ("Reward inactive",
                        [1, 2, 3], [42, 43, 44],
                        [0, 2], [42, 44],
                        0.45, -0.1, 0.1, 0.5,
                        [1, 0, 1]),
                       ("No segments",
                        [1, 2, 3], [42, 43, 44],
                        [], [42, 44],
                        0.45, 0.1, -0.1, 0.5,
                        [0, 0, 0]),
                       ("No active synapses",
                        [1, 2, 3], [42, 43, 44],
                        [0, 2], [],
                        0.45, 0.1, -0.1, 0.5,
                        [0, 0, 0]),
                       ("Delta of zero",
                        [1, 2, 3], [42, 43, 44],
                        [0, 2], [42, 44],
                        0.55, 0.0, 0.0, 0.5,
                        [3, 3, 3])
         ):

      connections = SparseMatrixConnections(2048, 2048)

      segments = connections.createSegments(cells)

      connections.growSynapses(segments, inputs, initialPermanence)
      connections.adjustSynapses(segments[adjustedSegments],
                                 activeInputs, activeDelta, inactiveDelta)

      overlaps = connections.computeActivity(inputs, connectedPermanence)

      np.testing.assert_equal(overlaps[segments], expected, name)
コード例 #3
0
    def test_whenPermanenceFallsBelowZero(self):
        connections = SparseMatrixConnections(2048, 2048)

        segments = connections.createSegments([1, 2, 3])

        connections.growSynapses(segments, [42, 43], 0.05)
        connections.adjustSynapses(segments, [42, 43], -0.06, 0.0)
        np.testing.assert_equal(
            connections.mapSegmentsToSynapseCounts(segments), [0, 0, 0])

        connections.growSynapses(segments, [42, 43], 0.05)
        connections.adjustSynapses(segments, [], 0.0, -0.06)
        np.testing.assert_equal(
            connections.mapSegmentsToSynapseCounts(segments), [0, 0, 0])

        connections.growSynapses(segments, [42, 43], 0.05)
        connections.adjustActiveSynapses(segments, [42, 43], -0.06)
        np.testing.assert_equal(
            connections.mapSegmentsToSynapseCounts(segments), [0, 0, 0])

        connections.growSynapses(segments, [42, 43], 0.05)
        connections.adjustInactiveSynapses(segments, [], -0.06)
        np.testing.assert_equal(
            connections.mapSegmentsToSynapseCounts(segments), [0, 0, 0])
コード例 #4
0
ファイル: connections_test.py プロジェクト: EricSB/nupic.core
  def test_whenPermanenceFallsBelowZero(self):
    connections = SparseMatrixConnections(2048, 2048)

    segments = connections.createSegments([1, 2, 3])

    connections.growSynapses(segments, [42, 43], 0.05)
    connections.adjustSynapses(segments, [42, 43], -0.06, 0.0)
    np.testing.assert_equal(connections.mapSegmentsToSynapseCounts(segments),
                            [0, 0, 0])

    connections.growSynapses(segments, [42, 43], 0.05)
    connections.adjustSynapses(segments, [], 0.0, -0.06)
    np.testing.assert_equal(connections.mapSegmentsToSynapseCounts(segments),
                            [0, 0, 0])

    connections.growSynapses(segments, [42, 43], 0.05)
    connections.adjustActiveSynapses(segments, [42, 43], -0.06)
    np.testing.assert_equal(connections.mapSegmentsToSynapseCounts(segments),
                            [0, 0, 0])

    connections.growSynapses(segments, [42, 43], 0.05)
    connections.adjustInactiveSynapses(segments, [], -0.06)
    np.testing.assert_equal(connections.mapSegmentsToSynapseCounts(segments),
                            [0, 0, 0])