hxtorch.spiking.modules.readout_neuron.Neuron

class hxtorch.spiking.modules.readout_neuron.Neuron(size: int, experiment: Experiment, leak: ModuleParameterType = 80, reset: ModuleParameterType = 80, threshold: ModuleParameterType = 125, tau_mem: ModuleParameterType = 1e-05, tau_syn: ModuleParameterType = 1e-05, i_synin_gm: ModuleParameterType = 500, membrane_capacitance: ModuleParameterType = 63, refractory_time: ModuleParameterType = 1e-06, synapse_dac_bias: ModuleParameterType = 600, holdoff_time: ModuleParameterType = 0.0, method: str = 'superspike', alpha: float = 50.0, execution_instance: Optional[ExecutionInstance] = None, enable_spike_recording: bool = True, enable_cadc_recording: bool = True, enable_cadc_recording_placement_in_dram: bool = False, enable_madc_recording: bool = False, record_neuron_id: Optional[int] = None, placement_constraint: Optional[List[halco.LogicalNeuronOnDLS]] = None, trace_offset: Union[Dict[halco.LogicalNeuronOnDLS, float], torch.Tensor, float] = 0.0, trace_scale: Union[Dict[halco.LogicalNeuronOnDLS, float], torch.Tensor, float] = 1.0, cadc_time_shift: int = 0, shift_cadc_to_first: bool = False, interpolation_mode: str = 'linear', neuron_structure: Optional[Morphology] = None, **extra_params)

Bases: hxtorch.spiking.modules.types.Population

Neuron layer

Caveat: For execution on hardware, this module can only be used in conjunction with a preceding Synapse module.

__init__(size: int, experiment: Experiment, leak: ModuleParameterType = 80, reset: ModuleParameterType = 80, threshold: ModuleParameterType = 125, tau_mem: ModuleParameterType = 1e-05, tau_syn: ModuleParameterType = 1e-05, i_synin_gm: ModuleParameterType = 500, membrane_capacitance: ModuleParameterType = 63, refractory_time: ModuleParameterType = 1e-06, synapse_dac_bias: ModuleParameterType = 600, holdoff_time: ModuleParameterType = 0.0, method: str = 'superspike', alpha: float = 50.0, execution_instance: Optional[ExecutionInstance] = None, enable_spike_recording: bool = True, enable_cadc_recording: bool = True, enable_cadc_recording_placement_in_dram: bool = False, enable_madc_recording: bool = False, record_neuron_id: Optional[int] = None, placement_constraint: Optional[List[halco.LogicalNeuronOnDLS]] = None, trace_offset: Union[Dict[halco.LogicalNeuronOnDLS, float], torch.Tensor, float] = 0.0, trace_scale: Union[Dict[halco.LogicalNeuronOnDLS, float], torch.Tensor, float] = 1.0, cadc_time_shift: int = 0, shift_cadc_to_first: bool = False, interpolation_mode: str = 'linear', neuron_structure: Optional[Morphology] = None, **extra_params)None

Initialize a Neuron. This module creates a population of spiking neurons of size size. This module has a internal spiking mask, which allows to disable the event output and spike recordings of specific neurons within the layer. This is particularly useful for dropout.

The neuron is parameterized by the `ModuleParameterType`d parameters:

leak, reset, threshold, tau_mem, tau_syn, i_synin_gm, membrane_capacitance, refractory_time, synapse_dac_bias, holdoff_time.

More infos to the respective parameters on BSS-2 can be found in calix.spiking.neuron.NeuronCalibTarget. If the parameters are not given as ParameterType, they are implicitly converted to HXParameter which provides the same value to the BSS-2 calibration (param.hardware_value) (and thus the hardware operation state) as to the numerical model (param.model_value) defined in forward_func. MixedHXModelParameter and HXTransformedModelParameter allow using different values on BSS-2 and in the numerics. This is useful if the dynamic range on hardware and in the numerical model differ. If so, the trace and weight scaling parameters need to be set accordingly in order to translate the weights to their corresponding hardware value and the hardware measurements into the dynamic range used in the numerics.

Parameters
  • size – Size of the population.

  • experiment – Experiment to append layer to.

  • execution_instance – Execution instance to place to.

  • leak – The leak potential. Defaults to HXParameter(80).

  • reset – The reset potential. Defaults to HXParameter(80).

  • threshold – The threshold potential. Defaults to HXParameter(125).

  • tau_syn – The synaptic time constant in s. Defaults to HXParameter(10e-6).

  • tau_mem – The membrane time constant in s. Defaults to HXParameter(10e-6).

  • i_synin_gm – A hardware parameter adjusting the hardware neuron -specific synaptic efficacy. Defaults to HXParameter(500).

  • membrane_capacitance – The capacitance of the membrane. The available range is 0 to approximately 2.2 pF, represented as 0 to 63 LSB.

  • refractory_time – The refractory time constant in s. Defaults to HXParameter(1e-6).

  • synapse_dac_bias – Synapse DAC bias current that is desired. Can be lowered in order to reduce the amplitude of a spike at the input of the synaptic input OTA. This can be useful to avoid saturation when using larger synaptic time constants. Defaults to HXParameter(600).

  • holdoff_time – Target length of the holdoff period in s. The holdoff period is the time at the end of the refractory period in which the clamping to the reset voltage is already released but new spikes can still not be generated. Defaults to HXParameter(0e-6).

  • enable_spike_recording – Boolean flag to enable or disable spike recording. Note, this does not disable the event out put of neurons. The event output has to be disabled via mask.

  • enable_cadc_recording – Enables or disables parallel sampling of the populations membrane trace via the CADC. A maximum sample rate of 1.7us is possible.

  • enable_cadc_recording_placement_in_dram – Whether to place CADC recording data into DRAM (period ~6us) or SRAM (period ~2us).

  • enable_madc_recording – Enables or disables the recording of the neurons record_neuron_id membrane trace via the MADC. Only a single neuron can be recorded. This membrane traces is samples with a significant higher resolution as with the CADC.

  • record_neuron_id – The in-population neuron index of the neuron to be recorded with the MADC. This has only an effect when enable_madc_recording is enabled.

  • placement_constraint – An optional list of logical neurons defining where to place the module`s neurons on hardware.

  • trace_offset – The value by which the measured CADC traces are shifted before the scaling is applied. If this offset is given as float the same value is applied to all neuron traces in this population. One can also provide a torch tensor holding one offset for each individual neuron in this population. The corresponding tensor has to be of size size. Further, the offsets can be supplied in a dictionary where the keys are the logical neuron coordinates and the values are the offsets, i.e. Dict[LogicalNeuronOnDLS, float]. The dictionary has to provide one coordinate for each hardware neuron represented by this population, but might also hold neuron coordinates that do not correspond to this layer. The layer-specific offsets are then picked and applied implicitly.

  • trace_scale – The value by which the measured CADC traces are scaled after the offset is applied. If this scale is given as float all neuron traces are scaled with the same value population. One can also provide a torch tensor holding one scale for each individual neuron in this population. The corresponding tensor has to be of size size. Further, the scales can be supplied in a dictionary where the keys are the logical neuron coordinates and the values are the scales, i.e. Dict[LogicalNeuronOnDLS, float]. The dictionary has to provide one coordinate for each hardware neuron represented by this population, but might also hold neuron coordinates that do not correspond to this layer. The layer- specific scales are then picked and applied implicitly.

  • cadc_time_shift – An integer indicating by how many time steps the CADC values are shifted in time. A positive value shifts later CADC samples to earlier times and vice versa for a negative value.

  • shift_cadc_to_first – A boolean indicating that the first measured CADC value is used as an offset. Note, this disables the param trace_offset.

  • interpolation_mode – The method used to interpolate the measured CADC traces onto the given time grid.

  • neuron_structure – Structure of the neuron. If not supplied a single neuron circuit is used.

Methods

__init__(size, experiment[, leak, reset, …])

Initialize a Neuron.

add_to_network_graph(builder)

Add the layer’s neurons to grenades network builder.

configure_hw_entity(neuron_id, neuron_block, …)

Configures a neuron in the given layer with its specific properties.

create_default_hw_entity()

At the moment, the default neuron is loaded from grenade’s ChipConfig object, which holds the atomic neurons configured as a calibration is loaded in hxtorch.hardware_init().

extra_repr()

Add additional information

forward_func(input[, hw_data])

post_process(hw_data, runtime)

User defined post process method called as soon as population-specific hardware observables are returned. This function has to convert the data types returned by grenade into PyTorch tensors. This function can be overridden by the user if non-default grenade-PyTorch data type conversion is required. Note: This function should return Tuple[Optional[torch.Tensor], …], like (cadc or madc,). This should match the ReadoutTensorHandle signature.

register_hw_entity()

Infer neuron IDs on hardware and register them.

Attributes

mask

Getter for spike mask.

add_to_network_graph(builder: _pygrenade_vx_network.NetworkBuilder)_pygrenade_vx_network.PopulationOnNetwork

Add the layer’s neurons to grenades network builder. If enable_spike_recording is enabled the neuron’s spikes are recorded according to the layer’s spiking mask. If no spiking mask is given all neuron spikes will be recorded. Note, the event output of the neurons are configured in configure_hw_entity. If enable_cadc_recording is enabled the populations neuron’s are registered for CADC membrane recording. If enable_madc_recording is enabled the neuron with in-population index record_neuron_id will be recording via the MADC. Note, since the MADC can only record a single neuron on hardware, other Neuron layers registering also MADC recording might overwrite the setting here.

Parameters

builder – Grenade’s network builder to add the layer’s population to.

Returns

Returns the builder with the population added.

configure_hw_entity(neuron_id: int, neuron_block: pylola_vx_v3.NeuronBlock, coord: pyhalco_hicann_dls_vx_v3.LogicalNeuronOnDLS)pylola_vx_v3.NeuronBlock

Configures a neuron in the given layer with its specific properties. The neurons digital event outputs are enabled according to the given spiking mask.

TODO: Additional parameterization should happen here, i.e. with

population-specific parameters.

Parameters
  • neuron_id – In-population neuron index.

  • neuron_block – The neuron block hardware entity.

  • coord – Coordinate of neuron on hardware.

Returns

Configured neuron block.

static create_default_hw_entity()pylola_vx_v3.AtomicNeuron

At the moment, the default neuron is loaded from grenade’s ChipConfig object, which holds the atomic neurons configured as a calibration is loaded in hxtorch.hardware_init().

TODO: - Needed?
  • Maybe this can return a default neuron, when pop-specific calibration is needed.

extra_repr()str

Add additional information

forward_func(input: hxtorch.spiking.handle.SynapseHandle, hw_data: Optional[Tuple[torch.Tensor]] = None)hxtorch.spiking.handle.NeuronHandle
property mask

Getter for spike mask.

Returns

Returns the current spike mask.

output_type

alias of hxtorch.spiking.handle.NeuronHandle

post_process(hw_data: HardwareObservables, runtime: float)Tuple[Optional[torch.Tensor], ]

User defined post process method called as soon as population-specific hardware observables are returned. This function has to convert the data types returned by grenade into PyTorch tensors. This function can be overridden by the user if non-default grenade-PyTorch data type conversion is required. Note: This function should return Tuple[Optional[torch.Tensor], …],

like (cadc or madc,). This should match the ReadoutTensorHandle signature.

Parameters
  • hw_data – A HardwareObservables instance holding the population’s recorded hardware observables.

  • runtime – The requested runtime of the experiment on hardware in s.

Returns

Returns a tuple of optional torch.Tensors holding the hardware data (madc or cadc,)

register_hw_entity()None

Infer neuron IDs on hardware and register them.