Skip to main content

Spiking neuron integration for Keras

Project description

Latest PyPI version Python versions Test coverage

KerasSpiking

KerasSpiking provides tools for training and running spiking neural networks directly within the Keras framework. The main feature is keras_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 as

inp = 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 inputs
inp = tf.keras.Input((None, 5))
dense = tf.keras.layers.Dense(10)(inp)
# replace Activation with SpikingActivation
act = 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 additional regularizers and filtering layers.

If you are interested in building and optimizing spiking neuron models, you may also be interested in NengoDL. See this page for a comparison of the different use cases supported by these two packages.

Documentation

Check out the documentation for

Release history

0.2.0 (February 18, 2021)

Compatible with TensorFlow 2.1.0 - 2.4.0

Added

  • Added the keras_spiking.Alpha filter, which provides second-order lowpass filtering for better noise removal for spiking layers. (#4)

  • Added keras_spiking.callbacks.DtScheduler, which can be used to update layer dt parameters during training. (#5)

  • Added keras_spiking.default.dt, which can be used to set the default dt for all layers that don’t directly specify dt. (#5)

  • Added keras_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 to keras_spiking.regularizers.L1L2/L1/L2 (so they can now be applied with respect to a single reference point or a range). (#6)

  • Added keras_spiking.regularizers.Percentile which computes a percentile across a number of examples, and regularize that statistic. (#6)

  • Added keras_spiking.ModelEnergy to estimate energy usage for Keras Models. (#7)

Changed

  • keras_spiking.SpikingActivation and keras_spiking.Lowpass now 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 of Conv2D layers). (#5)

Fixed

  • KerasSpiking layers’ reset_state now resets to the value of get_initial_state (as documented in the docstring), rather than all zeros. (#12)

  • Fixed a bug with keras_spiking.Alpha on 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.0

Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keras-spiking-0.2.0.tar.gz (58.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

keras_spiking-0.2.0-py3-none-any.whl (34.5 kB view details)

Uploaded Python 3

File details

Details for the file keras-spiking-0.2.0.tar.gz.

File metadata

  • Download URL: keras-spiking-0.2.0.tar.gz
  • Upload date:
  • Size: 58.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.7

File hashes

Hashes for keras-spiking-0.2.0.tar.gz
Algorithm Hash digest
SHA256 37a35c89031e30ebd66da1517ffad18bd2470017568ba1ff2cfed93e21e8f3dc
MD5 36aedd667166cb6ab4dd40acb53e2929
BLAKE2b-256 f5cd3034d6883cf97b3c8d37f032100531d22edf9e8bb280ae8aedf652475fb6

See more details on using hashes here.

File details

Details for the file keras_spiking-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: keras_spiking-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 34.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.7

File hashes

Hashes for keras_spiking-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6d92bf6afe08d8d461d2ce77d4720c499c181b928390736aae6bc8685e41abca
MD5 43e90faf3a76c0f33546e5859385e50e
BLAKE2b-256 def0abff4a0601636091503d8ea6c335f4ac3b2b14e31ea2fb26990ea28f18a7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page