SNABSuite  0.x
Spiking Neural Architecture Benchmark Suite
Classes | Namespaces | Typedefs | Enumerations | Functions
helper_functions.hpp File Reference
#include <assert.h>
#include <chrono>
#include <cmath>
#include <cypress/cypress.hpp>
#include <fstream>
#include <string>
#include <utility>

Go to the source code of this file.

Classes

struct  mnist_helper::CONVOLUTION_LAYER
 
struct  mnist_helper::POOLING_LAYER
 

Namespaces

 mnist_helper
 

Typedefs

typedef std::pair< std::vector< std::vector< Real > >, std::vector< uint16_t > > mnist_helper::MNIST_DATA
 
typedef std::pair< std::vector< std::vector< std::vector< Real > > >, std::vector< uint16_t > > mnist_helper::SPIKING_MNIST
 
typedef std::vector< std::vector< std::vector< std::vector< Real > > > > mnist_helper::CONVOLUTION_FILTER
 
typedef struct CONVOLUTION_LAYER mnist_helper::CONVOLUTION_LAYER
 
typedef struct POOLING_LAYER mnist_helper::POOLING_LAYER
 

Enumerations

Functions

MNIST_DATA mnist_helper::loadMnistData (const size_t num_data, const std::string path)
 Read in MNIST data from files. More...
 
void mnist_helper::print_image (const std::vector< Real > &img, size_t wrap)
 Prints image to std::cout. More...
 
std::vector< std::vector< std::vector< Real > > > mnist_helper::image_to_rate (const std::vector< std::vector< Real >> &images, const Real duration, const Real max_freq, size_t num_images, bool poisson=true)
 Converts a vector of images to a rate based representation. More...
 
SPIKING_MNIST mnist_helper::mnist_to_spike (const MNIST_DATA &mnist_data, const Real duration, const Real max_freq, size_t num_images, bool poisson=true)
 Converts the full MNIST dataset to a spiking MNIST dataset. More...
 
std::vector< MNIST_DATA > mnist_helper::create_batches (const SPIKING_MNIST &mnist_data, const size_t batch_size, Real duration, Real pause, const bool shuffle=false, unsigned seed=0)
 Creates batches of spikes representing the MNIST data. More...
 
cypress::Population< SpikeSourceArray > mnist_helper::create_spike_source (Network &netw, const MNIST_DATA &spikes)
 Creates Spike sources in network from spikes. More...
 
cypress::Population< SpikeSourceArray > & mnist_helper::update_spike_source (cypress::Population< SpikeSourceArray > &source, const MNIST_DATA &spikes)
 Update Spike sources in network from spikes. More...
 
Json mnist_helper::read_network (std::string path, bool msgpack=true)
 Read in the network file from json of msgpack. The Repo provides a script which creates compatible files. More...
 
template<typename T >
Real mnist_helper::max_weight (const T &json)
 Calculate the max weight, ignore negative values. More...
 
template<typename T >
Real mnist_helper::max_weight (const Matrix< T > &mat)
 Calculate the max weight, ignore negative values. More...
 
template<typename T >
Real mnist_helper::min_weight (const T &json)
 Calculate the min weight. More...
 
template<typename T >
Real mnist_helper::min_weight (const Matrix< T > &json)
 Calculate the min weight. More...
 
template<typename T >
Real mnist_helper::max_weight_abs (const T &json)
 Calculate the max absolute weight. More...
 
template<typename T >
Real mnist_helper::max_weight_abs (const Matrix< T > &json)
 Calculate the max absolute weight. More...
 
std::vector< LocalConnection > mnist_helper::dense_weights_to_conn (const Matrix< Real > &mat, Real scale, Real delay)
 Convert a dense layer to list of Local Connections. More...
 
std::vector< LocalConnection > mnist_helper::conv_weights_to_conn (const mnist_helper::CONVOLUTION_LAYER &layer, Real scale, Real delay)
 Converts a conv layer to list of Local Connections. More...
 
std::vector< std::vector< LocalConnection > > mnist_helper::pool_to_conn (const mnist_helper::POOLING_LAYER &layer, Real max_pool_weight, Real pool_inhib_weight, Real delay, Real pool_delay)
 
std::vector< uint16_t > mnist_helper::spikes_to_labels (const PopulationBase &pop, Real duration, Real pause, size_t batch_size)
 Converts the simulation results into label data. More...
 
void mnist_helper::conv_spikes_per_kernel (const std::string &filename, const PopulationBase &pop, Real duration, Real pause, size_t batch_size, Real norm=0.0)
 Saves the spikes of a convolution layer in a file. More...
 
std::vector< std::vector< Real > > mnist_helper::spikes_to_rates (const PopulationBase pop, Real duration, Real pause, size_t batch_size, Real norm=0.0)
 Converts the simulation results into values between 0 and 1. More...
 
size_t mnist_helper::compare_labels (std::vector< uint16_t > &label, std::vector< uint16_t > &res)
 Compare original labels with simulation labels, return number of correct labels. More...
 
std::vector< Real > mnist_helper::av_pooling_image (std::vector< Real > &image, size_t height, size_t width, size_t pooling_size)
 Downscale an image by average pooling. More...
 
MNIST_DATA mnist_helper::scale_mnist (MNIST_DATA &data, size_t pooling_size=3)
 downscale the complete MNIST dataset More...
 
SPIKING_MNIST mnist_helper::read_data_to_spike (const size_t num_images, bool train_data, const Real duration, const Real max_freq, bool poisson=true, bool scale_down=false)
 Reads in MNIST test or train data. More...
 
std::vector< LocalConnection > mnist_helper::conns_from_mat (const cypress::Matrix< Real > &weights, Real delay, Real scale_factor=0.0)
 Generate connection from given weight matrix. More...
 
void mnist_helper::update_conns_from_mat (const std::vector< cypress::Matrix< Real >> &weights, Network &netw, Real delay=1.0, Real scale_factor=0.0)
 Updates the connector is a given network with the weights provided. More...
 

Class Documentation

struct mnist_helper::CONVOLUTION_LAYER

Definition at line 38 of file helper_functions.hpp.

Class Members
CONVOLUTION_FILTER filter
vector< size_t > input_sizes
vector< size_t > output_sizes
size_t padding
size_t stride
struct mnist_helper::POOLING_LAYER

Definition at line 46 of file helper_functions.hpp.

Class Members
vector< size_t > input_sizes
vector< size_t > output_sizes
vector< size_t > size
size_t stride