• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python numpy.rmse函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nengo.utils.numpy.rmse函数的典型用法代码示例。如果您正苦于以下问题:Python rmse函数的具体用法?Python rmse怎么用?Python rmse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了rmse函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_scalar

def test_scalar(Simulator, nl):
    """A network that represents sin(t)."""
    N = 30

    m = nengo.Network(label='test_scalar', seed=123)
    with m:
        m.config[nengo.Ensemble].neuron_type = nl()
        input = nengo.Node(output=np.sin, label='input')
        A = nengo.Ensemble(N, 1, label='A')
        nengo.Connection(input, A)
        in_p = nengo.Probe(input, 'output')
        A_p = nengo.Probe(A, 'decoded_output', synapse=0.02)

    sim = Simulator(m)
    sim.run(5.0)

    with Plotter(Simulator, nl) as plt:
        t = sim.trange()
        plt.plot(t, sim.data[in_p], label='Input')
        plt.plot(t, sim.data[A_p], label='Neuron approximation, pstc=0.02')
        plt.legend(loc=0)
        plt.savefig('test_ensemble.test_scalar.pdf')
        plt.close()

    target = np.sin(np.arange(5000) / 1000.)
    target.shape = (-1, 1)
    logger.debug("Input RMSE: %f", npext.rmse(target, sim.data[in_p]))
    logger.debug("A RMSE: %f", npext.rmse(target, sim.data[A_p]))
    assert npext.rmse(target, sim.data[in_p]) < 0.001
    assert npext.rmse(target, sim.data[A_p]) < 0.1
开发者ID:goaaron,项目名称:blouw-etal-2015,代码行数:30,代码来源:test_ensemble.py


示例2: test_run

def test_run(Simulator, seed):
    rng = np.random.RandomState(seed)
    vocab = spa.Vocabulary(16, rng=rng)

    with spa.SPA(seed=seed, vocabs=[vocab]) as model:
        model.bind = spa.Bind(dimensions=16)

        def inputA(t):
            if 0 <= t < 0.1:
                return 'A'
            else:
                return 'B'

        model.input = spa.Input(bind_A=inputA, bind_B='A')

    bind, vocab = model.get_module_output('bind')

    with model:
        p = nengo.Probe(bind, 'output', synapse=0.03)

    sim = Simulator(model)
    sim.run(0.2)

    error = rmse(vocab.parse("B*A").v, sim.data[p][-1])
    assert error < 0.1

    error = rmse(vocab.parse("A*A").v, sim.data[p][100])
    assert error < 0.1
开发者ID:CamZHU,项目名称:nengo,代码行数:28,代码来源:test_bind.py


示例3: test_vector

def test_vector(Simulator, nl):
    """A network that represents sin(t), cos(t), arctan(t)."""
    N = 40

    m = nengo.Network(label='test_vector', seed=123)
    with m:
        m.config[nengo.Ensemble].neuron_type = nl()
        input = nengo.Node(
            output=lambda t: [np.sin(t), np.cos(t), np.arctan(t)])
        A = nengo.Ensemble(N * 3, 3, radius=2)
        nengo.Connection(input, A)
        in_p = nengo.Probe(input, 'output')
        A_p = nengo.Probe(A, 'decoded_output', synapse=0.02)

    sim = Simulator(m)
    sim.run(5)

    with Plotter(Simulator, nl) as plt:
        t = sim.trange()
        plt.plot(t, sim.data[in_p], label='Input')
        plt.plot(t, sim.data[A_p], label='Neuron approximation, pstc=0.02')
        plt.legend(loc='best', prop={'size': 10})
        plt.savefig('test_ensemble.test_vector.pdf')
        plt.close()

    target = np.vstack((np.sin(np.arange(5000) / 1000.),
                        np.cos(np.arange(5000) / 1000.),
                        np.arctan(np.arange(5000) / 1000.))).T
    logger.debug("In RMSE: %f", npext.rmse(target, sim.data[in_p]))
    assert npext.rmse(target, sim.data[in_p]) < 0.01
    assert npext.rmse(target, sim.data[A_p]) < 0.1
开发者ID:goaaron,项目名称:blouw-etal-2015,代码行数:31,代码来源:test_ensemble.py


示例4: run_param_set

    def run_param_set(self, n_neurons, d, seed, trial):
        seed = int(seed)
        n_neurons = int(n_neurons)
        d = int(d)

        rng = np.random.RandomState(seed)

        ctx = nengo.spa.SemanticPointer(d, rng)
        ctx.make_unitary()

        model = nengo.Network(seed=get_seed(rng))
        with model:
            in_a = nengo.Node(SignalGenerator(self.duration), size_out=d)
            in_b = nengo.Node(output=ctx.v)

            old_prod = nengo.networks.Product(n_neurons, d)
            old_result = nengo.Ensemble(1, 1, neuron_type=nengo.Direct())
            nengo.Connection(in_a, old_prod.A)
            nengo.Connection(in_b, old_prod.B)
            nengo.Connection(
                old_prod.output, old_result,
                transform=nengo.networks.product.dot_product_transform(d))

            prod = spaopt.Product(n_neurons, d)
            result = nengo.Ensemble(1, 1, neuron_type=nengo.Direct())
            nengo.Connection(in_a, prod.A)
            nengo.Connection(in_b, prod.B)
            nengo.Connection(
                prod.output, result,
                transform=nengo.networks.product.dot_product_transform(d))

            with nengo.Network() as net:
                net.config[nengo.Ensemble].neuron_type = nengo.Direct()
                d_prod = nengo.networks.EnsembleArray(2, d, 2)
                d_result = nengo.Ensemble(1, 1)
            nengo.Connection(in_a, d_prod.input[::2])
            nengo.Connection(in_b, d_prod.input[1::2])
            nengo.Connection(
                d_prod.add_output('dot', lambda x: x[0] * x[1]), d_result,
                transform=[d * [1.]])

            old_probe = nengo.Probe(old_result, synapse=None)
            probe = nengo.Probe(result, synapse=None)
            d_probe = nengo.Probe(d_result, synapse=None)

        sim = nengo.Simulator(model)
        sim.run(self.duration, progress_bar=False)

        return {
            't': sim.trange(),
            'default': rmse(sim.data[old_probe], sim.data[d_probe], axis=1),
            'optimized': rmse(sim.data[probe], sim.data[d_probe], axis=1)
        }
开发者ID:ctn-archive,项目名称:spaopt,代码行数:53,代码来源:benchmarks.py


示例5: test_product

def test_product(Simulator, nl):
    N = 80

    m = nengo.Network(label='test_product', seed=124)
    with m:
        m.config[nengo.Ensemble].neuron_type = nl()
        sin = nengo.Node(output=np.sin)
        cons = nengo.Node(output=-.5)
        factors = nengo.Ensemble(2 * N, dimensions=2, radius=1.5)
        factors.encoders = np.tile(
            [[1, 1], [-1, 1], [1, -1], [-1, -1]],
            (factors.n_neurons // 4, 1))
        product = nengo.Ensemble(N, dimensions=1)
        nengo.Connection(sin, factors[0])
        nengo.Connection(cons, factors[1])
        nengo.Connection(
            factors, product, function=lambda x: x[0] * x[1], synapse=0.01)

        sin_p = nengo.Probe(sin, 'output', sample_every=.01)
        # TODO
        # m.probe(conn, sample_every=.01)
        factors_p = nengo.Probe(
            factors, 'decoded_output', sample_every=.01, synapse=.01)
        product_p = nengo.Probe(
            product, 'decoded_output', sample_every=.01, synapse=.01)

    sim = Simulator(m)
    sim.run(6)

    with Plotter(Simulator, nl) as plt:
        t = sim.trange(dt=.01)
        plt.subplot(211)
        plt.plot(t, sim.data[factors_p])
        plt.plot(t, np.sin(np.arange(0, 6, .01)))
        plt.plot(t, sim.data[sin_p])
        plt.subplot(212)
        plt.plot(t, sim.data[product_p])
        # TODO
        # plt.plot(sim.data[conn])
        plt.plot(t, -.5 * np.sin(np.arange(0, 6, .01)))
        plt.savefig('test_ensemble.test_prod.pdf')
        plt.close()

    sin = np.sin(np.arange(0, 6, .01))
    assert npext.rmse(sim.data[factors_p][:, 0], sin) < 0.1
    assert npext.rmse(sim.data[factors_p][20:, 1], -0.5) < 0.1

    assert npext.rmse(sim.data[product_p][:, 0], -0.5 * sin) < 0.1
开发者ID:goaaron,项目名称:blouw-etal-2015,代码行数:48,代码来源:test_ensemble.py


示例6: test_oscillator

def test_oscillator(Simulator, nl, plt):
    model = nengo.Network(label='Oscillator', seed=789)
    with model:
        model.config[nengo.Ensemble].neuron_type = nl()
        inputs = {0: [1, 0], 0.5: [0, 0]}
        input = nengo.Node(piecewise(inputs), label='Input')

        tau = 0.1
        freq = 5
        T = nengo.networks.Oscillator(tau, freq,  n_neurons=100)
        nengo.Connection(input, T.input)

        A = nengo.Ensemble(100, dimensions=2)
        nengo.Connection(A, A, synapse=tau,
                         transform=[[1, -freq*tau], [freq*tau, 1]])
        nengo.Connection(input, A)

        in_probe = nengo.Probe(input)
        A_probe = nengo.Probe(A, synapse=0.01)
        T_probe = nengo.Probe(T.ensemble, synapse=0.01)

    sim = Simulator(model)
    sim.run(3.0)

    t = sim.trange()
    plt.plot(t, sim.data[A_probe], label='Manual')
    plt.plot(t, sim.data[T_probe], label='Template')
    plt.plot(t, sim.data[in_probe], 'k', label='Input')
    plt.legend(loc=0)

    assert rmse(sim.data[A_probe], sim.data[T_probe]) < 0.3
开发者ID:Tayyar,项目名称:nengo,代码行数:31,代码来源:test_oscillator.py


示例7: test_integrator

def test_integrator(Simulator, nl):
    model = nengo.Network(label='Integrator')
    with model:
        inputs = {0: 0, 0.2: 1, 1: 0, 2: -2, 3: 0, 4: 1, 5: 0}
        input = nengo.Node(piecewise(inputs))

        tau = 0.1
        T = nengo.networks.Integrator(tau, neurons=nl(100), dimensions=1)
        nengo.Connection(input, T.input, filter=tau)

        A = nengo.Ensemble(nl(100), dimensions=1)
        nengo.Connection(A, A, filter=tau)
        nengo.Connection(input, A, transform=tau, filter=tau)

        input_p = nengo.Probe(input, 'output')
        A_p = nengo.Probe(A, 'decoded_output', filter=0.01)
        T_p = nengo.Probe(T.ensemble, 'decoded_output', filter=0.01)

    sim = Simulator(model, dt=0.001)
    sim.run(6.0)

    with Plotter(Simulator, nl) as plt:
        t = sim.trange()
        plt.plot(t, sim.data[A_p], label='Manual')
        plt.plot(t, sim.data[T_p], label='Template')
        plt.plot(t, sim.data[input_p], 'k', label='Input')
        plt.legend(loc=0)
        plt.savefig('test_integrator.test_integrator.pdf')
        plt.close()

    assert rmse(sim.data[A_p], sim.data[T_p]) < 0.2
开发者ID:lisannehuurdeman,项目名称:nengo,代码行数:31,代码来源:test_integrator.py


示例8: test_integrator

def test_integrator(Simulator, nl, plt):
    model = nengo.Network(label='Integrator', seed=892)
    with model:
        model.config[nengo.Ensemble].neuron_type = nl()
        inputs = {0: 0, 0.2: 1, 1: 0, 2: -2, 3: 0, 4: 1, 5: 0}
        input = nengo.Node(piecewise(inputs))

        tau = 0.1
        T = nengo.networks.Integrator(tau, n_neurons=100, dimensions=1)
        nengo.Connection(input, T.input, synapse=tau)

        A = nengo.Ensemble(100, dimensions=1)
        nengo.Connection(A, A, synapse=tau)
        nengo.Connection(input, A, transform=tau, synapse=tau)

        input_p = nengo.Probe(input)
        A_p = nengo.Probe(A, synapse=0.01)
        T_p = nengo.Probe(T.ensemble, synapse=0.01)

    sim = Simulator(model, dt=0.001)
    sim.run(6.0)

    t = sim.trange()
    plt.plot(t, sim.data[A_p], label='Manual')
    plt.plot(t, sim.data[T_p], label='Template')
    plt.plot(t, sim.data[input_p], 'k', label='Input')
    plt.legend(loc=0)

    assert rmse(sim.data[A_p], sim.data[T_p]) < 0.2
开发者ID:Ocode,项目名称:nengo,代码行数:29,代码来源:test_integrator.py


示例9: test_sine_waves

def test_sine_waves(Simulator, plt, seed):
    radius = 2
    dim = 5
    product = nengo.networks.Product(
        200, dim, radius, net=nengo.Network(seed=seed))

    func_A = lambda t: np.sqrt(radius)*np.sin(np.arange(1, dim+1)*2*np.pi*t)
    func_B = lambda t: np.sqrt(radius)*np.sin(np.arange(dim, 0, -1)*2*np.pi*t)
    with product:
        input_A = nengo.Node(func_A)
        input_B = nengo.Node(func_B)
        nengo.Connection(input_A, product.A)
        nengo.Connection(input_B, product.B)
        p = nengo.Probe(product.output, synapse=0.005)

    with Simulator(product) as sim:
        sim.run(1.0)

    t = sim.trange()
    AB = np.asarray(list(map(func_A, t))) * np.asarray(list(map(func_B, t)))
    delay = 0.013
    offset = np.where(t >= delay)[0]

    for i in range(dim):
        plt.subplot(dim+1, 1, i+1)
        plt.plot(t + delay, AB[:, i])
        plt.plot(t, sim.data[p][:, i])
        plt.xlim(right=t[-1])
        plt.yticks((-2, 0, 2))

    assert rmse(AB[:len(offset), :], sim.data[p][offset, :]) < 0.2
开发者ID:4n6strider,项目名称:nengo,代码行数:31,代码来源:test_product.py


示例10: run_trial

    def run_trial():
        model = nengo.Network(seed=rng.randint(maxint))
        with model:
            model.config[nengo.Ensemble].n_eval_points = n_eval_points

            stimulus = nengo.Node(
                output=lambda t: stimulus_fn(max(0., t - wait_duration)),
                size_out=2)

            product_net = nengo.networks.Product(n_neurons, 1)
            nengo.Connection(stimulus[0], product_net.A)
            nengo.Connection(stimulus[1], product_net.B)
            probe_test = nengo.Probe(product_net.output)

            ens_direct = nengo.Ensemble(
                1, dimensions=2, neuron_type=nengo.Direct())
            result_direct = nengo.Node(size_in=1)
            nengo.Connection(stimulus, ens_direct)
            nengo.Connection(
                ens_direct, result_direct, function=lambda x: x[0] * x[1],
                synapse=None)
            probe_direct = nengo.Probe(result_direct)

        sim = nengo.Simulator(model)
        sim.run(duration + wait_duration, progress_bar=False)

        selection = sim.trange() > wait_duration
        test = sim.data[probe_test][selection]
        direct = sim.data[probe_direct][selection]
        return rmse(test, direct)
开发者ID:CamZHU,项目名称:nengo,代码行数:30,代码来源:test_product.py


示例11: test_sine_waves

def test_sine_waves(Simulator, plt, seed):
    radius = 2
    dim = 5
    product = nengo.networks.Product(200, dim, radius, seed=seed)

    func_a = lambda t: np.sqrt(radius)*np.sin(np.arange(1, dim+1)*2*np.pi*t)
    func_b = lambda t: np.sqrt(radius)*np.sin(np.arange(dim, 0, -1)*2*np.pi*t)
    with product:
        input_a = nengo.Node(func_a)
        input_b = nengo.Node(func_b)
        nengo.Connection(input_a, product.input_a)
        nengo.Connection(input_b, product.input_b)
        p = nengo.Probe(product.output, synapse=0.005)

    with Simulator(product) as sim:
        sim.run(1.0)

    t = sim.trange()
    ideal = (np.asarray([func_a(tt) for tt in t])
             * np.asarray([func_b(tt) for tt in t]))
    delay = 0.013
    offset = np.where(t >= delay)[0]

    for i in range(dim):
        plt.subplot(dim+1, 1, i+1)
        plt.plot(t + delay, ideal[:, i])
        plt.plot(t, sim.data[p][:, i])
        plt.xlim(right=t[-1])
        plt.yticks((-2, 0, 2))

    assert rmse(ideal[:len(offset), :], sim.data[p][offset, :]) < 0.2
开发者ID:nengo,项目名称:nengo,代码行数:31,代码来源:test_product.py


示例12: test_integrator

def test_integrator(Simulator, plt, seed):
    model = nengo.Network(seed=seed)
    with model:
        inputs = {0: 0, 0.2: 1, 1: 0, 2: -2, 3: 0, 4: 1, 5: 0}
        input = nengo.Node(Piecewise(inputs))

        tau = 0.1
        T = nengo.networks.Integrator(tau, n_neurons=100, dimensions=1)
        nengo.Connection(input, T.input, synapse=tau)

        A = nengo.Ensemble(100, dimensions=1)
        nengo.Connection(A, A, synapse=tau)
        nengo.Connection(input, A, transform=tau, synapse=tau)

        input_p = nengo.Probe(input, sample_every=0.01)
        A_p = nengo.Probe(A, synapse=0.01, sample_every=0.01)
        T_p = nengo.Probe(T.ensemble, synapse=0.01, sample_every=0.01)

    with Simulator(model) as sim:
        sim.run(6.0)

    t = sim.trange(sample_every=0.01)
    plt.plot(t, sim.data[A_p], label='Manual')
    plt.plot(t, sim.data[T_p], label='Template')
    plt.plot(t, sim.data[input_p], 'k', label='Input')
    plt.legend(loc='best')

    assert rmse(sim.data[A_p], sim.data[T_p]) < 0.1
开发者ID:nengo,项目名称:nengo,代码行数:28,代码来源:test_integrator.py


示例13: test_sine_waves

def test_sine_waves(Simulator, nl):
    radius = 2
    dim = 5
    product = nengo.networks.Product(
        200, dim, radius, neuron_type=nl(), seed=63)

    func_A = lambda t: np.sqrt(radius)*np.sin(np.arange(1, dim+1)*2*np.pi*t)
    func_B = lambda t: np.sqrt(radius)*np.sin(np.arange(dim, 0, -1)*2*np.pi*t)
    with product:
        input_A = nengo.Node(func_A)
        input_B = nengo.Node(func_B)
        nengo.Connection(input_A, product.A)
        nengo.Connection(input_B, product.B)
        p = nengo.Probe(product.output, synapse=0.005)

    sim = Simulator(product)
    sim.run(1.0)

    t = sim.trange()
    AB = np.asarray(list(map(func_A, t))) * np.asarray(list(map(func_B, t)))
    delay = 0.013
    offset = np.where(t >= delay)[0]

    with Plotter(Simulator, nl) as plt:
        for i in range(dim):
            plt.subplot(dim+1, 1, i+1)
            plt.plot(t + delay, AB[:, i])
            plt.plot(t, sim.data[p][:, i])
        plt.savefig('test_product.test_sine_waves.pdf')
        plt.close()

    assert rmse(AB[:len(offset), :], sim.data[p][offset, :]) < 0.2
开发者ID:bopo,项目名称:nengo,代码行数:32,代码来源:test_product.py


示例14: test_sine_waves

def test_sine_waves(Simulator, nl):
    radius = 2
    dim = 5
    product = nengo.networks.Product(nl(200), dim, radius)

    func_A = lambda t: radius*np.sin(np.arange(1, dim+1)*2*np.pi*t)
    func_B = lambda t: radius*np.sin(np.arange(dim, 0, -1)*2*np.pi*t)
    pstc = 0.003
    with product:
        input_A = nengo.Node(output=func_A)
        input_B = nengo.Node(output=func_B)
        nengo.Connection(input_A, product.A)
        nengo.Connection(input_B, product.B)
        p = nengo.Probe(product.output, synapse=pstc)

    sim = Simulator(product, seed=123)
    sim.run(1.0)

    t = sim.trange()
    AB = np.asarray(list(map(func_A, t))) * np.asarray(list(map(func_B, t)))
    delay = 0.011
    offset = np.where(t > delay)[0]

    with Plotter(Simulator) as plt:
        for i in range(dim):
            plt.subplot(dim+1, 1, i+1)
            plt.plot(t + delay, AB[:, i], label="$A \cdot B$")
            plt.plot(t, sim.data[p][:, i], label="Output")
            plt.legend()
        plt.savefig('test_product.test_sine_waves.pdf')
        plt.close()

    assert rmse(AB[:len(offset), :], sim.data[p][offset, :]) < 0.3
开发者ID:ZeitgeberH,项目名称:nengo,代码行数:33,代码来源:test_product.py


示例15: test_direct_mode_with_single_neuron

def test_direct_mode_with_single_neuron(Simulator, plt, seed):
    radius = 2
    dim = 5

    config = nengo.Config(nengo.Ensemble)
    config[nengo.Ensemble].neuron_type = nengo.Direct()
    with config:
        product = nengo.networks.Product(
            1, dim, radius, net=nengo.Network(seed=seed))

    func_A = lambda t: np.sqrt(radius)*np.sin(np.arange(1, dim+1)*2*np.pi*t)
    func_B = lambda t: np.sqrt(radius)*np.sin(np.arange(dim, 0, -1)*2*np.pi*t)
    with product:
        input_A = nengo.Node(func_A)
        input_B = nengo.Node(func_B)
        nengo.Connection(input_A, product.A)
        nengo.Connection(input_B, product.B)
        p = nengo.Probe(product.output, synapse=0.005)

    sim = Simulator(product)
    sim.run(1.0)

    t = sim.trange()
    AB = np.asarray(list(map(func_A, t))) * np.asarray(list(map(func_B, t)))
    delay = 0.013
    offset = np.where(t >= delay)[0]

    for i in range(dim):
        plt.subplot(dim+1, 1, i+1)
        plt.plot(t + delay, AB[:, i])
        plt.plot(t, sim.data[p][:, i])
    plt.xlim(right=t[-1])

    assert rmse(AB[:len(offset), :], sim.data[p][offset, :]) < 0.2
开发者ID:CamZHU,项目名称:nengo,代码行数:34,代码来源:test_product.py


示例16: test_oscillator

def test_oscillator(Simulator, plt, seed):
    model = nengo.Network(seed=seed)
    with model:
        inputs = {0: [1, 0], 0.5: [0, 0]}
        input = nengo.Node(Piecewise(inputs), label='Input')

        tau = 0.1
        freq = 5
        T = nengo.networks.Oscillator(tau, freq, n_neurons=100)
        nengo.Connection(input, T.input)

        A = nengo.Ensemble(100, dimensions=2)
        nengo.Connection(A, A, synapse=tau,
                         transform=[[1, -freq*tau], [freq*tau, 1]])
        nengo.Connection(input, A)

        in_probe = nengo.Probe(input, sample_every=0.01)
        A_probe = nengo.Probe(A, synapse=0.01, sample_every=0.01)
        T_probe = nengo.Probe(T.ensemble, synapse=0.01, sample_every=0.01)

    with Simulator(model) as sim:
        sim.run(3.0)

    t = sim.trange(sample_every=0.01)
    plt.plot(t, sim.data[A_probe], label='Manual')
    plt.plot(t, sim.data[T_probe], label='Template')
    plt.plot(t, sim.data[in_probe], 'k', label='Input')
    plt.legend(loc='best')

    assert rmse(sim.data[A_probe], sim.data[T_probe]) < 0.2
开发者ID:nengo,项目名称:nengo,代码行数:30,代码来源:test_oscillator.py


示例17: test_oscillator

def test_oscillator(Simulator, nl):
    model = nengo.Network(label='Oscillator', seed=789)
    with model:
        inputs = {0: [1, 0], 0.5: [0, 0]}
        input = nengo.Node(piecewise(inputs), label='Input')

        tau = 0.1
        freq = 5
        T = nengo.networks.Oscillator(
            tau, freq, label="Oscillator", neurons=nl(100))
        nengo.Connection(input, T.input)

        A = nengo.Ensemble(nl(100), label='A', dimensions=2)
        nengo.Connection(A, A, synapse=tau,
                         transform=[[1, -freq*tau], [freq*tau, 1]])
        nengo.Connection(input, A)

        in_probe = nengo.Probe(input, "output")
        A_probe = nengo.Probe(A, "decoded_output", synapse=0.01)
        T_probe = nengo.Probe(T.ensemble, "decoded_output", synapse=0.01)

    sim = Simulator(model)
    sim.run(3.0)

    with Plotter(Simulator, nl) as plt:
        t = sim.trange()
        plt.plot(t, sim.data[A_probe], label='Manual')
        plt.plot(t, sim.data[T_probe], label='Template')
        plt.plot(t, sim.data[in_probe], 'k', label='Input')
        plt.legend(loc=0)
        plt.savefig('test_oscillator.test_oscillator.pdf')
        plt.close()

    assert rmse(sim.data[A_probe], sim.data[T_probe]) < 0.3
开发者ID:ZeitgeberH,项目名称:nengo,代码行数:34,代码来源:test_oscillator.py


示例18: run_param_set

    def run_param_set(self, n_neurons, d, seed, trial):
        spaopt.optimization.SubvectorRadiusOptimizer.Simulator = \
            nengo_spinnaker.Simulator

        rng = np.random.RandomState(seed)

        ctx = nengo.spa.SemanticPointer(d, rng)
        ctx.make_unitary()

        model = nengo.Network(seed=get_seed(rng))
        with model:
            step = SignalGenerator(self.duration).make_step(0, d, .001, rng)
            in_a = nengo.Node(step, size_out=d)

            a = nengo.Node(size_in=d)
            b = nengo.Node(size_in=d)
            c = nengo.Node(size_in=d)
            nengo.Connection(in_a, a)
            nengo.Connection(a, b, synapse=None)
            nengo.Connection(b, c, synapse=None)

            old_repr = nengo.networks.EnsembleArray(n_neurons, d)
            nengo.Connection(in_a, old_repr.input)

            repr_ = spaopt.UnitEA(n_neurons, d, d)
            nengo.Connection(in_a, repr_.input)

            in_probe = nengo.Probe(c, synapse=0.005)
            old_probe = nengo.Probe(old_repr.output, synapse=0.005)
            probe = nengo.Probe(repr_.output, synapse=0.005)

        nengo_spinnaker.add_spinnaker_params(model.config)
        model.config[in_a].function_of_time = True
        sim = nengo_spinnaker.Simulator(model)
        sim.run(self.duration)
        sim.close()

        return {
            't': sim.trange(),
            'default': rmse(sim.data[old_probe], sim.data[in_probe], axis=1),
            'optimized': rmse(sim.data[probe], sim.data[in_probe], axis=1)
        }
开发者ID:ctn-archive,项目名称:spaopt,代码行数:42,代码来源:spinn.py


示例19: test_cchannelchain

def test_cchannelchain(Simulator, plt, rng, seed, outfile):
    dims = 2
    layers = 5
    n_neurons = 100
    synapse = nengo.Lowpass(0.01)

    with nengo.Network(seed=seed) as model:
        value = nengo.dists.UniformHypersphere().sample(
            dims, 1, rng=rng)[:, 0]
        stim = nengo.Node(value)

        ens = [nengo.Ensemble(n_neurons, dimensions=dims)
               for _ in range(layers)]

        nengo.Connection(stim, ens[0])
        for i in range(layers - 1):
            nengo.Connection(ens[i], ens[i+1], synapse=synapse)

        p_input = nengo.Probe(stim)
        p_outputs = [nengo.Probe(ens[i], synapse=synapse)
                     for i in range(layers)]

    sim = Simulator(model)
    sim.run(0.5)

    if type(plt).__name__ != 'Mock':
        figsize = (onecolumn, 4.0) if horizontal else (onecolumn * 2, 4.0)
        setup(figsize=figsize)
        colors = sns.cubehelix_palette(5)
        lines = []
        for i, p_output in enumerate(p_outputs):
            l = plt.plot(sim.trange(), sim.data[p_output],
                         c=colors[i % len(colors)])
            lines.append(l[0])
        plt.legend(lines, ["Ensemble %d" % i for i in range(1, 6)],
                   loc='best')
        plt.plot(sim.trange(), sim.data[p_input], c='k', lw=1)
        plt.xlim(right=0.12)
        plt.yticks((-0.5, 0, 0.5))
        plt.xticks((0, 0.05, 0.1))
        plt.ylabel('Decoded output')
        plt.xlabel('Time (s)')
        sns.despine()
        plt.saveas = 'results-1.svg'

    outfile.write('"n_neurons": %d,\n' % sum(
        e.n_neurons for e in model.all_ensembles))
    outfile.write('"simtime": 0.5,\n')
    outfile.write('"rmse": %f,\n' % (
        rmse(sim.data[p_outputs[-1]][sim.trange() > 0.4], value)))

    if hasattr(sim, 'close'):
        sim.close()
开发者ID:ctn-archive,项目名称:bekolay-fnme2015,代码行数:53,代码来源:benchmarks.py


示例20: test_product

def test_product(Simulator, nl):
    N = 80
    dt2 = 0.002
    f = lambda t: np.sin(6*t)

    m = nengo.Network(label='test_product', seed=124)
    with m:
        m.config[nengo.Ensemble].neuron_type = nl()
        sin = nengo.Node(output=f)
        cons = nengo.Node(output=-.5)
        factors = nengo.Ensemble(
            2 * N, 2, radius=1.5,
            encoders=Choice([[1, 1], [-1, 1], [1, -1], [-1, -1]]))
        product = nengo.Ensemble(N, dimensions=1)
        nengo.Connection(sin, factors[0])
        nengo.Connection(cons, factors[1])
        nengo.Connection(
            factors, product, function=lambda x: x[0] * x[1], synapse=0.01)

        factors_p = nengo.Probe(factors, sample_every=dt2, synapse=0.01)
        product_p = nengo.Probe(product, sample_every=dt2, synapse=0.01)

    sim = Simulator(m)
    sim.run(1)
    t = sim.trange(dt=dt2)

    with Plotter(Simulator, nl) as plt:
        plt.subplot(211)
        plt.plot(t, sim.data[factors_p])
        plt.legend(['factor 1', 'factor 2'])
        plt.subplot(212)
        plt.plot(t, -.5 * f(t), 'k--')
        plt.plot(t, sim.data[product_p])
        plt.legend(['exact product', 'neural product'], loc=4)
        plt.savefig('test_ensemble.test_product.pdf')
        plt.close()

    assert npext.rmse(sim.data[factors_p][:, 0], f(t)) < 0.1
    assert npext.rmse(sim.data[factors_p][20:, 1], -0.5) < 0.1
    assert npext.rmse(sim.data[product_p][:, 0], -0.5 * f(t)) < 0.1
开发者ID:bopo,项目名称:nengo,代码行数:40,代码来源:test_ensemble.py



注:本文中的nengo.utils.numpy.rmse函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python testing.allclose函数代码示例发布时间:2022-05-27
下一篇:
Python numpy.rms函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap