Esempio n. 1
0
    def test_defaults(self):
        G = LCAMechanism(integrator_mode=True,
                         leak=-1.0,
                         noise=0.0,
                         time_step_size=0.02,
                         function=Linear,
                         self_excitation=1.0,
                         competition=-1.0)

        # - - - - - LCAMechanism integrator functions - - - - -
        # X = previous_value + (rate * previous_value + variable) * self.time_step_size + noise
        # f(X) = 1.0*X + 0

        np.testing.assert_allclose(G.execute(), np.array([[0.0]]))
        # X = 0.0 + (0.0 + 0.0)*0.02 + 0.0
        # X = 0.0 <--- previous value 0.0
        # f(X) = 1.0*0.0  <--- return 0.0, recurrent projection 0.0

        np.testing.assert_allclose(G.execute(1.0), np.array([[0.02]]))
        # X = 0.0 + (0.0 + 1.0)*0.02 + 0.0
        # X = 0.02 <--- previous value 0.02
        # f(X) = 1.0*0.02  <--- return 0.02, recurrent projection 0.02

        # Outside of a system, previous value works (integrator) but recurrent projection does NOT
        np.testing.assert_allclose(G.execute(1.0), np.array([[0.0396]]))
Esempio n. 2
0
 def test_clip_float(self):
     L = LCAMechanism(clip=[-2.0, 2.0],
                      function=Linear,
                      leak=0.5,
                      integrator_mode=False)
     assert np.allclose(L.execute(3.0), 2.0)
     assert np.allclose(L.execute(-3.0), -2.0)
Esempio n. 3
0
 def test_clip_array(self):
     L = LCAMechanism(default_variable=[[0.0, 0.0, 0.0]],
                      clip=[-2.0, 2.0],
                      leak=0.5,
                      function=Linear,
                      integrator_mode=False)
     assert np.allclose(L.execute([3.0, 0.0, -3.0]), [2.0, 0.0, -2.0])
Esempio n. 4
0
 def test_clip_2d_array(self):
     L = LCAMechanism(default_variable=[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0],
                                        [0.0, 0.0, 0.0]],
                      clip=[-2.0, 2.0],
                      function=Linear,
                      integrator_mode=False)
     assert np.allclose(
         L.execute([[-5.0, -1.0, 5.0], [5.0, -5.0, 1.0], [1.0, 5.0, 5.0]]),
         [[-2.0, -1.0, 2.0], [2.0, -2.0, 1.0], [1.0, 2.0, 2.0]])