The modules in this package provide functionality to load and process datasets into the SNN conversion toolbox.


The main purpose of this module is to load a dataset from disk and feed it to the toolbox in one of the formats it can handle.

For details see

get_dataset Get dataset, either from .npz files or keras.ImageDataGenerator.

@author: rbodo


Get dataset, either from .npz files or keras.ImageDataGenerator.

Returns Dictionaries with keys x_test and y_test if data set was loaded in .npz format, or with dataflow key if data will be loaded from .jpg, .png, or .bmp files by a keras.ImageDataGenerator.

Parameters:config (configparser.ConfigParser) – Settings.
  • normset (dict) – Used to normalized the network parameters.
  • testset (dict) – Used to test the networks.

Instead of loading a normalization data set to calculate scale-factors, try to get the scale-factors stored on disk during a previous run.

Parameters:config (configparser.ConfigParser) – Settings.
Returns:A dictionary with single key ‘scale_facs’. The corresponding value is itself a dictionary containing the scale factors for each layer. Returns empty set if no scale factors were found.
Return type:Union[dict, None]
snntoolbox.datasets.utils.to_categorical(y, nb_classes)[source]

Convert class vector to binary class matrix.

If the input y has shape (nb_samples,) and contains integers from 0 to nb_classes, the output array will be of dimension (nb_samples, nb_classes).

snntoolbox.datasets.utils.load_npz(path, filename)[source]

Load dataset from an .npz file.

  • filename (string) – Name of file.
  • path (string) – Location of dataset to load.

The dataset as a numpy array containing samples.

Return type: