コード例 #1
0
def run_forever_not_recorded():
    sim.setup(1.0)
    stim = sim.Population(1, sim.SpikeSourcePoisson(rate=10.0))
    pop = sim.Population(255, sim.IF_curr_exp(tau_syn_E=1.0), label="pop")
    sim.Projection(
        stim, pop, sim.AllToAllConnector(), sim.StaticSynapse(weight=20.0))
    conn = DatabaseConnection(
        start_resume_callback_function=start_callback,
        stop_pause_callback_function=stop_callback, local_port=None)
    SpynnakerExternalDevicePluginManager.add_database_socket_address(
        conn.local_ip_address, conn.local_port, None)
    sim.external_devices.run_forever()
    sim.end()
コード例 #2
0
def run_forever_recorded():
    sim.setup(1.0)
    source_spikes = range(0, 5000, 100)
    stim = sim.Population(1, sim.SpikeSourceArray(source_spikes))
    pop = sim.Population(255, sim.IF_curr_exp(tau_syn_E=1.0), label="pop")
    sim.Projection(stim, pop, sim.AllToAllConnector(),
                   sim.StaticSynapse(weight=20.0))
    pop.record(["v", "spikes"])
    conn = DatabaseConnection(start_resume_callback_function=start_callback,
                              stop_pause_callback_function=stop_callback,
                              local_port=None)
    SpynnakerExternalDevicePluginManager.add_database_socket_address(
        conn.local_ip_address, conn.local_port, None)
    sim.external_devices.run_forever()

    spikes = pop.get_data("spikes").segments[0].spiketrains
    sim.end()
    for spiketrain in spikes:
        assert (len(spiketrain) > 0)
        for spike, source in zip(spiketrain, source_spikes[:len(spiketrain)]):
            assert (spike > source)
            assert (spike < source + 10)
コード例 #3
0
ファイル: __init__.py プロジェクト: Starborn/sPyNNaker8
def EthernetControlPopulation(n_neurons,
                              model,
                              label=None,
                              local_host=None,
                              local_port=None,
                              database_notify_port_num=None,
                              database_ack_port_num=None):
    """ Create a PyNN population that can be included in a network to\
        control an external device which is connected to the host

    :param n_neurons: The number of neurons in the control population
    :param model:\
        Class of a model that creates a vertex of type\
        AbstractEthernetController
    :param label: An optional label for the population
    :param local_host:\
        The optional local host IP address to listen on for commands
    :param local_port: The optional local port to listen on for commands
    :param database_ack_port_num:\
        The optional port to which responses to the database notification\
        protocol are to be sent
    :param database_notify_port_num:\
        The optional port to which notifications from the database\
        notification protocol are to be sent
    :return:\
        A pyNN Population which can be used as the target of a Projection.\
        Note that the Population can also be used as the source of a\
        Projection, but it might not send spikes.
    """
    # pylint: disable=protected-access, too-many-arguments, too-many-locals
    population = Population(n_neurons, model, label=label)
    vertex = population._get_vertex
    if not isinstance(vertex, AbstractEthernetController):
        raise Exception(
            "Vertex must be an instance of AbstractEthernetController")
    translator = vertex.get_message_translator()
    live_packet_gather_label = "EthernetControlReceiver"
    global __ethernet_control_connection
    if __ethernet_control_connection is None:
        __ethernet_control_connection = EthernetControlConnection(
            translator, vertex.label, live_packet_gather_label, local_host,
            local_port)
        add_database_socket_address(
            __ethernet_control_connection.local_ip_address,
            __ethernet_control_connection.local_port, database_ack_port_num)
    else:
        __ethernet_control_connection.add_translator(vertex.label, translator)
    devices_with_commands = [
        device for device in vertex.get_external_devices()
        if isinstance(device, AbstractSendMeMulticastCommandsVertex)
    ]
    if devices_with_commands:
        ethernet_command_connection = EthernetCommandConnection(
            translator, devices_with_commands, local_host,
            database_notify_port_num)
        add_database_socket_address(
            ethernet_command_connection.local_ip_address,
            ethernet_command_connection.local_port, database_ack_port_num)
    Plugins.update_live_packet_gather_tracker(
        population._vertex,
        live_packet_gather_label,
        port=__ethernet_control_connection.local_port,
        hostname=__ethernet_control_connection.local_ip_address,
        message_type=EIEIOType.KEY_PAYLOAD_32_BIT,
        payload_as_time_stamps=False,
        use_payload_prefix=False,
        partition_ids=vertex.get_outgoing_partition_ids())
    return population
コード例 #4
0
Y_BITS = 8

# Game resolution
X_RESOLUTION = 160
Y_RESOLUTION = 128

# UDP port to read spikes from
UDP_PORT1 = 17893
UDP_PORT2 = 17894

# Setup pyNN simulation
p.setup(timestep=1.0)

# Create breakout population and activate live output for it
breakout_pop = p.Population(1, spinn_breakout.Breakout, {}, label="breakout")
ex.activate_live_output_for(breakout_pop, host="0.0.0.0", port=UDP_PORT1)
ex.activate_live_output_for(breakout_pop, host="0.0.0.0", port=UDP_PORT2)

# Create spike injector to send random spikes to the paddle
spike_array = [[0, 2, 4, 6, 8, 10], [1, 3, 5, 7, 9, 11]]

# Connect key spike injector to breakout population
# array_input = p.Population(2, p.SpikeSourceArray(spike_times=spike_array), label="input_connect")
# poisson = p.SpikeSourcePoisson(rate=20)
rate = {'rate': 2}  #, 'duration': 10000000}
spike_input = p.Population(2,
                           p.SpikeSourcePoisson,
                           rate,
                           label="input_connect")
p.Projection(spike_input, breakout_pop, p.AllToAllConnector(weights=2))
# key_input_connection = SpynnakerLiveSpikesConnection(send_labels=["input_connect"])
コード例 #5
0
ファイル: __init__.py プロジェクト: chanokin/sPyNNaker7
# injector
from spynnaker.pyNN.models.utility_models \
    import SpikeInjector as ExternalDeviceSpikeInjector

# useful functions
add_database_socket_address = \
    SpynnakerExternalDevicePluginManager.add_database_socket_address
activate_live_output_to = \
    SpynnakerExternalDevicePluginManager.activate_live_output_to
activate_live_output_for = \
    SpynnakerExternalDevicePluginManager.activate_live_output_for


logger = logging.getLogger(__name__)

spynnaker_external_devices = SpynnakerExternalDevicePluginManager()


__all__ = [
    "EIEIOType",

    # General Devices
    "ExternalCochleaDevice", "ExternalFPGARetinaDevice",
    "MunichRetinaDevice", "MunichMotorDevice",
    "ArbitraryFPGADevice", "PushBotRetinaViewer",

    # Pushbot Parameters
    "MunichIoSpiNNakerLinkProtocol",
    "PushBotLaser", "PushBotLED", "PushBotMotor", "PushBotSpeaker",
    "PushBotRetinaResolution",
コード例 #6
0
# Game resolution sampling factors
x_factor1 = 2
y_factor1 = x_factor1
bricking = 1

# -----------------------------------------------------------------------------
# Create Spiking Neural Network
# -----------------------------------------------------------------------------

# Create breakout population and activate live output
b1 = gym.Breakout(x_factor=x_factor1, y_factor=y_factor1, bricking=bricking)
breakout_pop = p.Population(b1.neurons(), b1, label="breakout1")

# ex is the external device plugin manager
ex.activate_live_output_for(breakout_pop)

# Connect key spike injector to breakout population
key_input = p.Population(2, SpikeInjector, label="key_input")
key_input_connection = SpynnakerLiveSpikesConnection(send_labels=["key_input"])
p.Projection(key_input, breakout_pop, p.AllToAllConnector(),
             p.StaticSynapse(weight=0.1))

# Create random spike input and connect to Breakout pop to stimulate paddle
# (and enable paddle visualisation)
spike_input = p.Population(2,
                           p.SpikeSourcePoisson(rate=2),
                           label="input_connect")
p.Projection(spike_input, breakout_pop, p.AllToAllConnector(),
             p.StaticSynapse(weight=0.1))