The Spiking Heidelberg datasets for spiking neural networks

Here we provide two new spiking datasets for the evaluation of spiking neural networks. The Spiking Heidelberg Digits (SHD) dataset and the Spiking Speech Command (SSC) dataset are both audio-based classification datasets for which input spikes and output labels are provided. The datasets are released under the Creative Commons Attribution 4.0 International License.

Digit examples

Publication

When using these data or the code for your work, please cite:

Cramer, B., Stradmann, Y., Schemmel, J., and Zenke, F. (2022). The Heidelberg Spiking Data Sets for the Systematic Evaluation of Spiking Neural Networks. IEEE Transactions on Neural Networks and Learning Systems 33, 2744–2757. https://doi.org/10.1109/TNNLS.2020.3044364.

Download

https://compneuro.net/datasets/

Mirrors: https://zenkelab.org/datasets/ and https://ieee-dataport.org/open-access/heidelberg-spiking-datasets

Specifications

We provide two distinct classification datasets for spiking neural networks.

Name Classes Samples (train/valid/test) Parent dataset URL
SHD 20 8156/-/2264 Heidelberg Digits (HD) https://compneuro.net/datasets/hd_audio.tar.gz
SSC 35 75466/9981/20382 Speech Commands v0.2 https://arxiv.org/abs/1804.03209

Both datasets are based on respective audio datasets. Spikes in 700 input channels were generated using an artificial cochlea model. The conversion model is freely available from https://github.com/electronicvisions/lauscher . The SHD consists of approximately 10000 high-quality aligned studio recordings of spoken digits from 0 to 9 in both German and English language. Recordings exist of 12 distinct speakers two of which are only present in the test set. The SSC is based on the Speech Commands release by Google which consists of utterances recorded from a larger number of speakers under less controlled conditions. It contains 35 word categories from a larger number of speakers.

SHD Leaderboard

For the leaderboard see https://zenkelab.org/resources/spiking-heidelberg-datasets-shd/

Data format

For maximum compatibility, the SHD datasets are provided in HDF5 format which can be read by most major programming languages.

root
|-spikes
   |-times[]
   |-units[]
|-labels[]
|-extra
   |-speaker[]
   |-keys[]
   |-meta_info
      |-gender[]
      |-age[]
      |-body_height[]

Each datum consists of two lists that contain the firing times and the unit id of which neuron has fired at the corresponding firing time.

Example code

For a tutorial how to train a spiking neural network on this dataset checkout: https://github.com/fzenke/spytorch/blob/master/notebooks/SpyTorchTutorial4.ipynb

The following code illustrates howto download and access the dataset in Python. The example code uses the PyTables package (https://www.pytables.org) to load HDF5 files.

import os
import urllib.request
import gzip, shutil
from tensorflow.keras.utils import get_file


cache_dir=os.path.expanduser("~/data")
cache_subdir="hdspikes"
print("Using cache dir: %s"%cache_dir)

# The remote directory with the data files
base_url = "https://compneuro.net/datasets"

# Retrieve MD5 hashes from remote
response = urllib.request.urlopen("%s/md5sums.txt"%base_url)
data = response.read() 
lines = data.decode('utf-8').split("\n")
file_hashes = { line.split()[1]:line.split()[0] for line in lines if len(line.split())==2 }

def get_and_gunzip(origin, filename, md5hash=None):
    gz_file_path = get_file(filename, origin, md5_hash=md5hash, cache_dir=cache_dir, cache_subdir=cache_subdir)
    hdf5_file_path=gz_file_path[:-3]
    if not os.path.isfile(hdf5_file_path) or os.path.getctime(gz_file_path) > os.path.getctime(hdf5_file_path):
        print("Decompressing %s"%gz_file_path)
        with gzip.open(gz_file_path, 'r') as f_in, open(hdf5_file_path, 'wb') as f_out:
            shutil.copyfileobj(f_in, f_out)
    return hdf5_file_path



# Download the Spiking Heidelberg Digits (SHD) dataset
files = [ "shd_train.h5.gz", 
          "shd_test.h5.gz",
        ]

for fn in files:
    origin = "%s/%s"%(base_url,fn)
    hdf5_file_path = get_and_gunzip(origin, fn, md5hash=file_hashes[fn])
    print(hdf5_file_path)


# Similarly, to download the SSC dataset
files = [ "ssc_train.h5.gz", 
          "ssc_valid.h5.gz",
          "ssc_test.h5.gz",
        ]

for fn in files:
    origin = "%s/%s"%(base_url,fn)
    hdf5_file_path = get_and_gunzip(origin,fn,md5hash=file_hashes[fn])
    print(hdf5_file_path)



# At this point we can visualize some of the data

import tables
import numpy as np

fileh = tables.open_file(hdf5_file_path, mode='r')
units = fileh.root.spikes.units
times = fileh.root.spikes.times
labels = fileh.root.labels

# This is how we access spikes and labels
index = 0
print("Times (ms):", times[index])
print("Unit IDs:", units[index])
print("Label:", labels[index])


# A quick raster plot for one of the samples
import matplotlib.pyplot as plt

fig = plt.figure(figsize=(16,4))
idx = np.random.randint(len(times),size=3)
for i,k in enumerate(idx):
    ax = plt.subplot(1,3,i+1)
    ax.scatter(times[k],700-units[k], color="k", alpha=0.33, s=2)
    ax.set_title("Label %i"%labels[k])
    ax.axis("off")

plt.show()

Audio spike conversion model

The artificial cochlear model used for converting the datasets is freely available at https://github.com/electronicvisions/lauscher

License

Copyright 2019-2020 Benjamin Cramer & Friedemann Zenke

This work is licensed under a Creative Commons Attribution 4.0 International License.

About compneuro.net

compneuro.net is here to hosts a (random) selection of useful resources for computational neuroscience. It is currently maintained by Friedemann Zenke https://fzenke.net If you have something to contribute, please get in touch.

Thanks for reading!