Beispiel #1
0
    def test_vector_input_constant(self):
        # Adjust these values to change the matrix dimensions
        #  Matrix A is D1xD2
        #  Matrix B is D2xD3
        #  result is D1xD3
        D1 = 1
        D2 = 2
        seed = 123
        N = 50

        net=Network('Matrix Multiplication', seed=seed,
                   Simulator=self.Simulator)

        # make 2 matrices to store the input
        print "make_array: input matrices A and B"
        net.make_array('A', neurons=N, array_size=D1*D2, 
            neuron_type='lif')

        # connect inputs to them so we can set their value
        net.make_input('input A', value=[.5, -.5])
        net.connect('input A', 'A')
        inprobe = net.make_probe('input A', dt_sample=0.01, pstc=0.1)
        sprobe = net._probe_signals(
            net.ensembles['A'].input_signals, dt_sample=0.01, pstc=0.01)
        Aprobe = net.make_probe('A', dt_sample=0.01, pstc=0.1)

        net.run(1)

        in_data = inprobe.get_data()
        s_data = sprobe.get_data()
        A_data = Aprobe.get_data()

        plt.subplot(311); plt.plot(in_data)
        plt.subplot(312); plt.plot(s_data)
        plt.subplot(313); plt.plot(A_data)
        if self.show:
            plt.show()

        assert np.allclose(in_data[-10:], [.5, -.5], atol=.01, rtol=.01)
        assert np.allclose(s_data[-10:], [.5, -.5], atol=.01, rtol=.01)
        assert np.allclose(A_data[-10:], [.5, -.5], atol=.01, rtol=.01)