Class SpikingNetwork
Defined in File SpikingNetwork.h
Class Documentation
-
class SpikingNetwork
Spiking Neural Network (SNN) composed of layers of spiking neurons. Layers have to be successively added from input to outputs. SpikingNetwork uses the JITCompiler to compile and load custom source files containing kernel callbacks.
Public Types
Public Functions
-
SpikingNetwork(const std::string &compile_path = default_compile_path)
Constructs an empty SNN.
- Parameters
compile_path – Compilation path for custom kernel callback sources.
-
~SpikingNetwork()
Destructor. Deletes layer, unload custom kernel callback dynamic libraries and delete JITCompiler.
Adds a layer of type LayerType with the given arguments to the network. The added layer uses the default kernel during inference.
- Template Parameters
LayerType – Type of layer to add. Must inherit from Layer.
Args – Types of arguments passed to the new layer constructor.
- Parameters
args – Arguments passed to the new layer constructor.
- Returns
Shared pointer on the new layer.
Adds a layer of type LayerType with a custom kernel callbacks source. If not already used, the given source file is compiled and loaded by the JITCompiler.
- Template Parameters
LayerType – Type of layer to add. Must inherit from Layer.
Args – Types of arguments passed to the new layer constructor.
- Parameters
src_path – Path to the kernel callbacks source file.
args – Arguments passed to the new layer constructor.
- Throws
std::runtime_error – if the given source file failed to compile.
std::runtime_error – with the result of dlerror() if the compiled dynamic library could not be loaded.
- Returns
Shared pointer on the new layer.
-
const SpikeArray &infer(const SpikeArray &pre_spikes)
Infer the entire SNN using the given sorteed input spike array.
- Parameters
pre_spikes – Sorted input spikes.
- Throws
std::runtime_error – if pre_spikes are not sorted.
- Returns
Constant reference on the output spike array.
-
template<class IndicesType, class TimesType>
inline const SpikeArray &infer(const IndicesType &indices, const TimesType ×) Infer the entire SNN using the given input spike indices and times.
- Template Parameters
IndicesType – Type of spike indices
TimesType – Type of spike times
- Parameters
indices – Input spike indices.
times – Input spike times.
- Returns
Constant reference on the output spike array.
Gets the layer at the specified index.
- Template Parameters
T – Type of index.
- Parameters
idx – The index of the layer.
- Returns
A shared pointer on the requested layer.
-
std::shared_ptr<Layer> get_output_layer()
Gets the output layer.
- Returns
A shared pointer on the last layer.
-
unsigned int get_n_layers() const
Gets the number of layers.
- Returns
The number of layers.
Public Static Attributes
-
static constexpr char default_compile_path[] = "/tmp/evspikesim"
Default compilation path for custom kernel callback sources.
-
SpikingNetwork(const std::string &compile_path = default_compile_path)