qualia_plugin_snn.preprocessing package

Submodules

Module contents

Qualia-Plugin-SNN preprocessing package contains preprocessing modules adapted for or dedicated to Spiking Neural Networks.

class qualia_plugin_snn.preprocessing.Group2TimeStepsBySample[source]

Bases: Preprocessing[RawDataModel, RawDataModel]

Preprocessing module to group frame data from same sample into timesteps.

__call__(datamodel: RawDataModel) RawDataModel[source]

Group frames from the same samples of from a qualia_core.datamodel.RawDataModel.RawDataModel into timesteps.

Relies on sample indices (begin, end) from the info array to only group frames from the same sample.

Input data should be 2D or 1D (+ channel) with [N, H, W, C] order (channels_last). Output data has [N // T, T, H, W, C] dimensions Extra data from a sample that do not fit in a timestep group is truncated.

Parameters:

datamodel (RawDataModel) – The input dataset

Returns:

The dataset with additional timestep dimension

Return type:

RawDataModel

__init__(timesteps: int) None[source]

Construct qualia_plugin_snn.preprocessing.Group2TimeStepsBySample.Group2TimeStepsBySample.

Parameters:

timesteps (int) – Number of timesteps to group frames from a sample

Return type:

None

class qualia_plugin_snn.preprocessing.IntegrateEventsByFixedDuration[source]

Bases: Preprocessing[EventDataModel, RawDataModel]

Preprocessing module to construct fixed-duration frames from event data.

__call__(datamodel: EventDataModel) RawDataModel[source]

Construct frames from events of the same sample of a qualia_plugin_snn.datamodel.EventDataModel.EventDataModel.

Relies on sample indices (begin, end) from the info array to only collect events from the same sample.

Input data should be 2D event data with (t, x, y, p) columns or 1D event data with (t, x, p) columns. Output data has [N, H, W, C] or [N, W, C] dimensions

Uses SpikingJelly’s implementation of spikingjelly.datasets.integrate_events_segment_to_frame()

Parameters:

datamodel (EventDataModel) – The input event-based dataset

Returns:

The new frame dataset

Return type:

RawDataModel

__init__(duration: int) None[source]

Construct qualia_plugin_snn.preprocessing.IntegrateEventsByFixedDuration.IntegrateEventsByFixedDuration.

Parameters:

duration (int) – Duration of frame

Return type:

None

import_data(dataset: Dataset[Any]) Dataset[Any][source]
Parameters:

dataset (Dataset[Any])

Return type:

Dataset[Any]

class qualia_plugin_snn.preprocessing.IntegrateEventsByFixedFramesNumber[source]

Bases: IntegrateEventsByFixedDuration

Preprocessing module to construct fixed number of frames from a sample of event data.

__call__(datamodel: EventDataModel) RawDataModel[source]

Construct frames from events of the same sample of a qualia_plugin_snn.datamodel.EventDataModel.EventDataModel.

Relies on sample indices (begin, end) from the info array to only collect events from the same sample.

Input data should be 2D event data with (t, x, y, p) columns or 1D event data with (t, x, p) columns. Output data has [N, H, W, C] or [N, W, C] dimensions

Uses a derivative of SpikingJelly’s implementation of spikingjelly.datasets.integrate_events_by_fixed_frames_number()

Parameters:

datamodel (EventDataModel) – The input event-based dataset

Returns:

The new frame dataset

Return type:

RawDataModel

__init__(split_by: str, frames_num: int) None[source]

Construct qualia_plugin_snn.preprocessing.IntegrateEventsByFixedFramesNumber.IntegrateEventsByFixedFramesNumber.

Parameters:
  • split_by (str) – 'time' or 'number', see spikingjelly.datasets.cal_fixed_frames_number_segment_index()

  • frames_num (int) – Number of frames to produce per sample

Return type:

None

import_data(dataset: Dataset[Any]) Dataset[Any][source]
Parameters:

dataset (Dataset[Any])

Return type:

Dataset[Any]

class qualia_plugin_snn.preprocessing.Split2TimeSteps[source]

Bases: Preprocessing[RawDataModel, RawDataModel]

Preprocessing module to split 1D input dataset into multiple timesteps.

__call__(datamodel: RawDataModel) RawDataModel[source]

Split the given qualia_core.datamodel.RawDataModel.RawDataModel into multiple timesteps.

Input data should be 1D (+ channel) with [N, S, C] order (channels_last). Output data has [N, T, S // T, C] dimensions Extra data that do not fit in a chunk is truncated.

Parameters:

datamodel (RawDataModel) – The input dataset

Returns:

The dataset with additional timestep dimension

Return type:

RawDataModel

__init__(chunks: int) None[source]

Construct qualia_plugin_snn.preprocessing.Split2TimeSteps.Split2TimeSteps.

Parameters:

chunks (int) – Number of chunks to split the data into

Return type:

None