Package: keras-spiking
KerasSpikingKerasSpiking provides tools for training and running spiking neural networks
directly within the Keras framework. The main feature iskeras_spiking.SpikingActivation, which can be used to transform
any activation function into a spiking equivalent. For example, we can translate a
non-spiking model, such asinp=tf.keras.Input((5,))dense=tf.keras.layers.Dense(10)(inp)act=tf.keras.layers.Activation("relu")(dense)model=tf.keras.Model(inp,act)into the spiking equivalent:# add time dimension to inputsinp=tf.keras.Input((None,5))dense=tf.keras.layers.Dense(10)(inp)# replace Activation with SpikingActivationact=keras_spiking.SpikingActivation("relu")(dense)model=tf.keras.Model(inp,act)Models with SpikingActivation layers can be optimized and evaluated in the same way as
any other Keras model. They will automatically take advantage of KerasSpiking’s
“spiking aware training”: using the spiking activations on the forward pass and the
non-spiking (differentiable) activation function on the backwards pass.KerasSpiking also includes various tools to assist in the training of spiking models,
such as additionalregularizersandfiltering layers.If you are interested in building and optimizing spiking neuron models, you may also
be interested inNengoDL. Seethis pagefor a
comparison of the different use cases supported by these two packages.DocumentationCheck out thedocumentationforInstallation instructionsMore detailed example introducing the features of KerasSpikingAPI referenceRelease history0.3.0 (November 8, 2021)Compatible with TensorFlow 2.1.0 - 2.7.0AddedLowpassCell,Lowpass,AlphaCell, andAlphalayers now accept bothinitial_level_constraintandtau_constraintto customize how their
respective parameters are constrained during training. (#21)ChangedThetautime constants forLowpassCell,Lowpass,AlphaCell, andAlphaare now always clipped to be positive in the forward pass rather than
constraining the underlying trainable weights in between gradient updates. (#21)Renamed theLowpass/Alphatauparameter totau_initializer, and it now
acceptstf.keras.initializers.Initializerobjects (in addition to floats, as
before).  Renamed thetau_varweight attribute totau. (#21)FixedSpikingActivation,Lowpass, andAlphalayers will now correctly usekeras_spiking.default.dt. (#20)0.2.0 (February 18, 2021)Compatible with TensorFlow 2.1.0 - 2.4.0AddedAdded thekeras_spiking.Alphafilter, which provides second-order lowpass
filtering for better noise removal for spiking layers. (#4)Addedkeras_spiking.callbacks.DtScheduler, which can be used to update layerdtparameters during training. (#5)Addedkeras_spiking.default.dt, which can be used to set the defaultdtfor all layers that don’t directly specifydt. (#5)Addedkeras_spiking.regularizers.RangedRegularizer, which can be used to apply
some other regularizer (e.g.tf.keras.regularizers.L2) with respect to some
non-zero target point, or a range of acceptable values. This functionality has also
been added tokeras_spiking.regularizers.L1L2/L1/L2(so they can now be applied
with respect to a single reference point or a range). (#6)Addedkeras_spiking.regularizers.Percentilewhich computes a percentile across a
number of examples, and regularize that statistic. (#6)Addedkeras_spiking.ModelEnergyto estimate energy usage for Keras Models. (#7)Changedkeras_spiking.SpikingActivationandkeras_spiking.Lowpassnow return sequences
by default. This means that these layers will now have outputs that have the same
number of timesteps as their inputs. This makes it easier to process create
multi-layer spiking networks, where time is preserved throughout the network.
The spiking fashion-MNIST example has been updated accordingly. (#3)Layers now support multi-dimensional inputs (e.g., output ofConv2Dlayers).
(#5)FixedKerasSpiking layers’reset_statenow resets to the value ofget_initial_state(as documented in the docstring), rather than all zeros. (#12)Fixed a bug withkeras_spiking.Alphaon TensorFlow 2.1, where a symbolic tensor
in the initial state shape could not be converted to a Numpy array. (#16)0.1.0 (August 14, 2020)Compatible with TensorFlow 2.1.0 - 2.3.0Initial release