Exemple #1
0
    def do_all_constraint(self):
        synfire_run = SynfireRunner()
        synfire_run.do_run(n_neurons,
                           neurons_per_core=neurons_per_core,
                           delay=delay,
                           run_times=[runtime],
                           placement_constraint=placement_constraint,
                           record=True,
                           record_7=True,
                           record_v=True,
                           record_v_7=True,
                           record_gsyn_exc=True,
                           record_gsyn_exc_7=True,
                           record_gsyn_inh=False)

        gsyn_exc = synfire_run.get_output_pop_gsyn_exc_numpy()
        v = synfire_run.get_output_pop_voltage_numpy()
        spikes = synfire_run.get_output_pop_spikes_numpy()

        self.assertEqual(n_neurons * runtime, len(gsyn_exc))
        read_gsyn = numpy.loadtxt(gysn_file, delimiter=',')
        self.assertTrue(numpy.allclose(read_gsyn, gsyn_exc, rtol=1e-04),
                        "gsyn neo method mismatch")

        self.assertEqual(n_neurons * runtime, len(v))
        read_v = numpy.loadtxt(v_file, delimiter=',')
        self.assertTrue(numpy.allclose(read_v, v, rtol=1e-03),
                        "v neo method mismatch")

        self.assertEqual(expected_spikes, len(spikes))
        spike_checker.synfire_spike_checker(spikes, n_neurons)
        read_spikes = numpy.loadtxt(spike_file, delimiter=',')
        self.assertTrue(numpy.allclose(read_spikes, spikes),
                        "spikes neo method mismatch")
Exemple #2
0
    def do_v_no_constraint(self):
        synfire_run = SynfireRunner()
        synfire_run.do_run(n_neurons,
                           neurons_per_core=neurons_per_core,
                           delay=delay,
                           run_times=[runtime],
                           record=False,
                           record_v=True,
                           record_gsyn_exc_7=False,
                           record_gsyn_inh=False)
        v = synfire_run.get_output_pop_voltage_numpy()

        self.assertEqual(n_neurons * runtime, len(v))
        read_v = numpy.loadtxt(v_file, delimiter=',')
        self.assertTrue(numpy.allclose(read_v, v, rtol=1e-03),
                        "v neo method mismatch")
Exemple #3
0
    def do_gsyn_no_constraint(self):
        synfire_run = SynfireRunner()
        synfire_run.do_run(n_neurons,
                           neurons_per_core=neurons_per_core,
                           delay=delay,
                           run_times=[runtime],
                           record=False,
                           record_v=False,
                           record_gsyn_exc_7=True,
                           record_gsyn_inh=False)
        gsyn_exc = synfire_run.get_output_pop_gsyn_exc_numpy()

        self.assertEqual(n_neurons * runtime, len(gsyn_exc))
        read_gsyn = numpy.loadtxt(gysn_file, delimiter=',')
        self.assertTrue(numpy.allclose(read_gsyn, gsyn_exc, rtol=1e-04),
                        "gsyn neo method mismatch")
Exemple #4
0
    def get_before_and_after(self):
        synfire_run = SynfireRunner()
        synfire_run.do_run(n_neurons, neurons_per_core=neurons_per_core,
                           weight_to_spike=weight_to_spike, delay=delay,
                           placement_constraint=placement_constraint,
                           run_times=runtimes, get_weights=get_weights,
                           get_delays=get_delays)
        weights = synfire_run.get_weights()
        self.assertEqual(n_neurons, len(weights[0]))
        self.assertEqual(n_neurons, len(weights[1]))
        self.assertTrue(numpy.allclose(weights[0][0][2], weights[1][0][2]))

        delays = synfire_run.get_delay()
        self.assertEqual(n_neurons, len(delays[0]))
        self.assertEqual(n_neurons, len(delays[1]))
        self.assertTrue(numpy.allclose(delays[0][0][2], delays[1][0][2]))
Exemple #5
0
    def do_all_no_constraint(self):
        synfire_run = SynfireRunner()
        synfire_run.do_run(n_neurons,
                           neurons_per_core=neurons_per_core,
                           delay=delay,
                           run_times=[runtime],
                           record=True,
                           record_7=True,
                           record_v=True,
                           record_v_7=True,
                           record_gsyn_exc=True,
                           record_gsyn_exc_7=True,
                           record_gsyn_inh=False)
        gsyn_exc_7 = synfire_run.get_output_pop_gsyn_exc_7()
        v_7 = synfire_run.get_output_pop_voltage_7()
        spikes_7 = synfire_run.get_output_pop_spikes_7()

        gsyn_exc = synfire_run.get_output_pop_gsyn_exc_numpy()
        v = synfire_run.get_output_pop_voltage_numpy()
        spikes = synfire_run.get_output_pop_spikes_numpy()

        self.assertEqual(n_neurons * runtime, len(gsyn_exc))
        read_gsyn = numpy.loadtxt(gysn_file, delimiter=',')
        if not numpy.allclose(read_gsyn, gsyn_exc_7):
            for g1, g2 in zip(read_gsyn, gsyn_exc_7):
                if not numpy.allclose(g1, g2, rtol=1e-04):
                    print(g1, g2, g1[2] - g2[2], (g1[2] - g2[2]) / g1[2])

        self.assertTrue(numpy.allclose(read_gsyn, gsyn_exc_7, rtol=1e-04),
                        "gsyn synakker method mismatch")
        self.assertTrue(numpy.allclose(read_gsyn, gsyn_exc, rtol=1e-04),
                        "gsyn neo method mismatch")

        self.assertEqual(n_neurons * runtime, len(v))
        read_v = numpy.loadtxt(v_file, delimiter=',')
        self.assertTrue(numpy.allclose(read_v, v_7, rtol=1e-03),
                        "v synakker method mismatch")
        self.assertTrue(numpy.allclose(read_v, v, rtol=1e-03),
                        "v neo method mismatch")

        self.assertEqual(expected_spikes, len(spikes))
        spike_checker.synfire_spike_checker(spikes, n_neurons)
        read_spikes = numpy.loadtxt(spike_file, delimiter=',')
        self.assertTrue(numpy.allclose(read_spikes, spikes_7),
                        "spikes synakker method mismatch")
        self.assertTrue(numpy.allclose(read_spikes, spikes),
                        "spikes neo method mismatch")
Exemple #6
0
    def do_spikes_no_constraint(self):
        synfire_run = SynfireRunner()
        synfire_run.do_run(n_neurons,
                           neurons_per_core=neurons_per_core,
                           delay=delay,
                           run_times=[runtime],
                           record=True,
                           record_v=False,
                           record_gsyn_exc_7=False,
                           record_gsyn_inh=False)
        spikes = synfire_run.get_output_pop_spikes_numpy()

        self.assertEqual(expected_spikes, len(spikes))
        spike_checker.synfire_spike_checker(spikes, n_neurons)
        read_spikes = numpy.loadtxt(spike_file, delimiter=',')
        self.assertTrue(numpy.allclose(read_spikes, spikes),
                        "spikes neo method mismatch")
Exemple #7
0
        read_gsyn = numpy.loadtxt(gysn_file, delimiter=',')
        self.assertTrue(numpy.allclose(read_gsyn, gsyn_exc, rtol=1e-04),
                        "gsyn neo method mismatch")

    def test_gsyn_no_constraint(self):
        self.runsafe(self.do_gsyn_no_constraint)


if __name__ == '__main__':
    synfire_run = SynfireRunner()
    synfire_run.do_run(n_neurons,
                       neurons_per_core=neurons_per_core,
                       delay=delay,
                       run_times=[runtime],
                       placement_constraint=placement_constraint,
                       record=True,
                       record_7=True,
                       record_v=True,
                       record_v_7=True,
                       record_gsyn_exc=True,
                       record_gsyn_exc_7=True,
                       record_gsyn_inh=False)

    gsyn_exc = synfire_run.get_output_pop_gsyn_exc_numpy()
    gsyn_exc_neo = synfire_run.get_output_pop_gsyn_exc_neo()
    v = synfire_run.get_output_pop_voltage_numpy()
    v_neo = synfire_run.get_output_pop_voltage_neo()
    spikes = synfire_run.get_output_pop_spikes_numpy()
    spikes_neo = synfire_run.get_output_pop_spikes_neo()

    numpy.savetxt(spike_file, spikes, delimiter=',')
    numpy.savetxt(v_file, v, delimiter=',')
                               neurons_per_core=neurons_per_core,
                               run_times=[runtime])
            spikes = synfire_run.get_output_pop_spikes_numpy()
            # CB Currently eight but could change
            # Needs to be larger than 1000 timesteps version
            self.assert_logs_messages(lc.records,
                                      "*** Running simulation... ***", 'INFO',
                                      3)

        self.assertEqual(158, len(spikes))
        spike_checker.synfire_spike_checker(spikes, n_neurons)
        synfire_run.get_output_pop_gsyn_exc_numpy()
        synfire_run.get_output_pop_voltage_numpy()

    def more_runs(self):
        self.runsafe(self.more_runs)


if __name__ == '__main__':
    synfire_run.do_run(n_neurons,
                       neurons_per_core=neurons_per_core,
                       run_times=[runtime])
    gsyn = synfire_run.get_output_pop_gsyn_exc_numpy()
    v = synfire_run.get_output_pop_voltage_numpy()
    spikes = synfire_run.get_output_pop_spikes_numpy()

    print(len(spikes))
    plot_utils.plot_spikes(spikes)
    plot_utils.heat_plot(v)
    plot_utils.heat_plot(gsyn)
Exemple #9
0
        self.assertTrue(numpy.allclose(weights[0][0][2], weights[1][0][2]))

        delays = synfire_run.get_delay()
        self.assertEqual(n_neurons, len(delays[0]))
        self.assertEqual(n_neurons, len(delays[1]))
        self.assertTrue(numpy.allclose(delays[0][0][2], delays[1][0][2]))

    def test_get_before_and_after(self):
        self.runsafe(self.get_before_and_after)


if __name__ == '__main__':
    synfire_run = SynfireRunner()
    synfire_run.do_run(n_neurons, neurons_per_core=neurons_per_core,
                       weight_to_spike=weight_to_spike, delay=delay,
                       placement_constraint=placement_constraint,
                       run_times=runtimes, get_weights=get_weights,
                       get_delays=get_delays)
    weights = synfire_run.get_weights()
    delays = synfire_run.get_delay()
    print("weights[0]")
    print(weights[0])
    print(weights[0].shape)
    print("weights[1]")
    print(weights[1])
    print(weights[1].shape)
    print("delays[0]")
    print(delays[0])
    print(delays[0].shape)
    print("delays[1]")
    print(delays[1])
                           input_class=input_class,
                           start_time=start_time,
                           duration=duration,
                           rate=rate,
                           extract_between_runs=extract_between_runs,
                           set_between_runs=set_between_runs,
                           seed=12345)
        spikes = synfire_run.get_output_pop_spikes_numpy()
        # Check spikes increase in second half by at least a factor of ten
        hist = numpy.histogram(spikes[:, 1], bins=[0, 5000, 10000])
        self.assertLess(hist[0][0] * 10, hist[0][1])

    def test_synfire_poisson_if_curr_exp_parameter(self):
        self.runsafe(self.synfire_poisson_if_curr_exp_parameter)


if __name__ == '__main__':
    synfire_run.do_run(n_neurons,
                       neurons_per_core=neurons_per_core,
                       run_times=run_times,
                       input_class=input_class,
                       start_time=start_time,
                       duration=duration,
                       rate=rate,
                       extract_between_runs=extract_between_runs,
                       set_between_runs=set_between_runs)
    spikes = synfire_run.get_output_pop_spikes_numpy()
    hist = numpy.histogram(spikes[:, 1], bins=[0, 5000, 10000])
    print(hist[0][0] * 10, hist[0][1])
    plot_utils.plot_spikes(spikes)