예제 #1
0
def test_signal_indexing_1():
    m = SimModel()
    one = m.signal(1)
    two = m.signal(2)
    three = m.signal(3)

    m.filter(1, three[0:1], one)
    m.filter(2.0, three[1:], two)
    m.filter([[0, 0, 1], [0, 1, 0], [1, 0, 0]], three, three)

    sim = Simulator(m)
    sim.signals[three] = np.asarray([1, 2, 3])
    sim.step()
    assert np.all(sim.signals[one] == 1)
    assert np.all(sim.signals[two] == [4, 6])
    assert np.all(sim.signals[three] == [3, 2, 1])
    sim.step()
    assert np.all(sim.signals[one] == 3)
    assert np.all(sim.signals[two] == [4, 2])
    assert np.all(sim.signals[three] == [1, 2, 3])
예제 #2
0
def test_simple_direct_mode():
    m = SimModel()
    one, steps, simtime = setup_simtime(m)
    sig = m.signal()

    pop = m.nonlinearity(Direct(n_in=1, n_out=1, fn=np.sin))
    m.encoder(simtime, pop, weights=[[1.0]])
    m.decoder(pop, sig, weights=[[1.0]])
    m.transform(1.0, sig, sig)

    sim = Simulator(m)
    for i in range(5):
        sim.step()
        if i:
            assert sim.signals[sig] == np.sin(sim.signals[simtime] - 0.001)
예제 #3
0
    def _test_cconv(self, D, neurons_per_product):
        # D is dimensionality of semantic pointers

        m = SimModel(.001)
        rng = np.random.RandomState(1234)

        A = m.signal(D, value=rng.randn(D))
        B = m.signal(D, value=rng.randn(D))

        CircularConvolution(m, A, B,
            neurons_per_product=neurons_per_product)

        sim = self.Simulator(m)
        sim.run_steps(10)

        raise nose.SkipTest()