Neko: a Library for Exploring Neuromorphic Learning Rules

Zixuan Zhao, Nathan Wycoff, Neil Getty, Rick Stevens, Fangfang Xia

Introduction

While deep learning has achieved remarkable success in tasks ranging from computer vision to natural language processing, it remains significantly less energy-efficient and data-efficient than the biological brain. This disparity has fueled the growth of neuromorphic computing, which utilizes Spiking Neural Networks (SNNs) and brain-inspired learning rules to achieve biological levels of efficiency. However, a significant "software gap" exists: standard frameworks like PyTorch and TensorFlow are optimized for backpropagation, while existing neuromorphic tools often focus on inference or biological simulation rather than training from scratch with novel algorithms.

Neko is an open-source Python library designed to bridge this gap. By providing a modular "middle layer" that supports both PyTorch and TensorFlow backends, Neko allows researchers to prototype, debug, and compare neuromorphic learning rules like e-prop and Manhattan rules with ease.

Modular Architecture and Methods

Neko’s architecture is built on four primary modules that allow for a "mix-and-match" approach to model design, decoupling the learning rule from the training process and the model architecture itself.

Overview of Neko's modular workflow from input encoding to application.
  • Layer: This module includes pre-implemented SNN components, such as Leaky Integrate-and-Fire (LIF) and Adaptive LIF (ALIF) neurons, alongside adaptors for standard Keras and PyTorch models.
  • Evaluator: This component associates models with specific loss functions and performance metrics.
  • Learning Rule: The core of the library, implementing algorithms like e-prop (a biologically plausible alternative to backpropagation through time) and Manhattan rules (designed for hardware-constrained analog training).
  • Trainer: This module manages the logistics of the training loop and enables advanced logic, such as the simultaneous execution of multiple learning rules for direct comparison.

The Gradient Comparison Tool

A standout feature of Neko is its Gradient Comparison Tool. Many neuromorphic rules are essentially approximations of the gradients used in standard backpropagation. Neko allows developers to visualize exactly how much a custom rule deviates from "true" backpropagation gradients on a batch-by-batch basis. This provides a powerful debugging mechanism to understand why certain rules may underperform or fail to converge.

Visualization of gradient approximation used for debugging neuromorphic learning rules.

Experimental Evaluation

The authors evaluated Neko across a diverse range of benchmarks to demonstrate its versatility and performance:

  • Speech Recognition (TIMIT): Used to test temporal credit assignment in sequential data.
  • Handwritten Digit Recognition (MNIST & MNIST-1D): Testing both static and sequential image classification.
  • Medical Robotics (Surgery Kinematic Dataset): Measuring instrument positions during simulated medical exercises.
  • Healthcare (ECG Heartbeat Categorization): A public dataset for heartbeat classification.

Key Insights and Results

Neko's modular approach yielded several significant findings:

  1. State-of-the-Art Accuracy: On the TIMIT speech benchmark, Neko’s implementation of e-prop achieved a 27% reduction in error compared to the original algorithm's reference paper, matching the performance of a non-spiking LSTM baseline.
  2. Hardware-Aware Simulation: By implementing Manhattan rules, Neko demonstrated that hardware-constrained learning (simulating memristive crossbars) could achieve 96% accuracy on MNIST, only 2% lower than standard backpropagation. This proves the viability of training directly on analog hardware.
  3. Automated Derivations: Traditionally, implementing e-prop required manual, error-prone mathematical derivations for different network types. Neko automates this process using a symbolic approach tied to recurrent cell dynamics, significantly lowering the barrier to entry for researchers.
  4. Uncertainty Quantification: The library's Hybrid Monte Carlo (HMC) implementation successfully associated incorrect predictions with higher uncertainty, a critical requirement for safety-critical AI applications.

Conclusion and Future Work

Neko provides a robust foundation for the neuromorphic research community by simplifying the implementation and analysis of brain-inspired learning rules. While current support focuses on standard LIF/ALIF neurons, future versions aim to include more complex structures like dendritic computation and direct integration with physical neuromorphic chips like Intel’s Loihi. The authors also plan to expand the library to include more probabilistic learning approaches, such as Variational Bayes and Monte Carlo Dropout.

The source code is available at: https://github.com/cortical-team/neko

Summary updated

BibTeX
@inproceedings{zhao2021neko,
  author = {Zixuan Zhao and Nathan Wycoff and Neil Getty and Rick Stevens and Fangfang Xia},
  title = {{Neko: a Library for Exploring Neuromorphic Learning Rules}},
  booktitle = {ICONS},
  year = {2021},
  url = {https://openreview.net/forum?id=PrYZ3LTKSN},
}
Figure