23 #include <cypress/cypress.hpp>    31 typedef std::pair<std::vector<std::vector<Real>>, std::vector<uint16_t>>
    33 typedef std::pair<std::vector<std::vector<std::vector<Real>>>,
    34                   std::vector<uint16_t>>
    36 typedef std::vector<std::vector<std::vector<std::vector<Real>>>>
    71 void print_image(
const std::vector<Real> &img, 
size_t wrap);
    84     const std::vector<std::vector<Real>> &images, 
const Real duration,
    85     const Real max_freq, 
size_t num_images, 
bool poisson = 
true);
    99                              const Real max_freq, 
size_t num_images,
   100                              bool poisson = 
true);
   117                                        Real pause, 
const bool shuffle = 
false,
   138     cypress::Population<SpikeSourceArray> &source, 
const MNIST_DATA &spikes);
   148 Json 
read_network(std::string path, 
bool msgpack = 
true);
   156 template <
typename T>
   160     for (
size_t i = 0; 
i < json.size(); 
i++) {
   161         for (
size_t j = 0; j < json[
i].size(); j++) {
   162             Real tmp = Real(json[
i][j]);
   177 template <
typename T>
   181     for (
size_t i = 0; 
i < mat.size(); 
i++) {
   182         Real tmp = Real(mat[
i]);
   196 template <
typename T>
   200     for (
size_t i = 0; 
i < json.size(); 
i++) {
   201         for (
size_t j = 0; j < json[
i].size(); j++) {
   202             Real tmp = Real(json[
i][j]);
   217 template <
typename T>
   221     for (
size_t i = 0; 
i < json.size(); 
i++) {
   222         Real tmp = Real(json[
i]);
   236 template <
typename T>
   240     for (
size_t i = 0; 
i < json.size(); 
i++) {
   241         for (
size_t j = 0; j < json[
i].size(); j++) {
   242             Real tmp = fabs(Real(json[
i][j]));
   257 template <
typename T>
   261     for (
size_t i = 0; 
i < json.size(); 
i++) {
   262         Real tmp = fabs(Real(json[
i]));
   279                                                    Real scale, Real delay);
   290                                                   Real scale, Real delay);
   304     Real pool_inhib_weight, Real delay, Real pool_delay);
   317 std::vector<uint16_t> 
spikes_to_labels(
const PopulationBase &pop, Real duration,
   318                                        Real pause, 
size_t batch_size);
   331                             Real duration, Real pause, 
size_t batch_size, Real norm = 0.0);
   345 std::vector<std::vector<Real>> 
spikes_to_rates(
const PopulationBase pop,
   346                                                Real duration, Real pause,
   370                                    size_t width, 
size_t pooling_size);
   393                                  const Real duration, 
const Real max_freq,
   394                                  bool poisson = 
true, 
bool scale_down = 
false);
   405     const cypress::Matrix<Real> &weights, Real delay, Real scale_factor = 0.0);
   417                            Network &netw, Real delay = 1.0,
   418                            Real scale_factor = 0.0);
 std::vector< size_t > output_sizes
std::vector< std::vector< std::vector< Real > > > 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. 
std::vector< MNIST_DATA > 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. 
std::vector< std::vector< LocalConnection > > pool_to_conn(const mnist_helper::POOLING_LAYER &layer, Real max_pool_weight, Real pool_inhib_weight, Real delay, Real pool_delay)
std::vector< Real > av_pooling_image(std::vector< Real > &image, size_t height, size_t width, size_t pooling_size)
Downscale an image by average pooling. 
std::vector< LocalConnection > dense_weights_to_conn(const Matrix< Real > &mat, Real scale, Real delay)
Convert a dense layer to list of Local Connections. 
Real max_weight_abs(const T &json)
Calculate the max absolute weight. 
std::vector< LocalConnection > conv_weights_to_conn(const mnist_helper::CONVOLUTION_LAYER &layer, Real scale, Real delay)
Converts a conv layer to list of Local Connections. 
MNIST_DATA scale_mnist(MNIST_DATA &data, size_t pooling_size=3)
downscale the complete MNIST dataset 
Json 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 fi...
std::vector< LocalConnection > conns_from_mat(const cypress::Matrix< Real > &weights, Real delay, Real scale_factor=0.0)
Generate connection from given weight matrix. 
void print_image(const std::vector< Real > &img, size_t wrap)
Prints image to std::cout. 
CONVOLUTION_FILTER filter
Real min_weight(const T &json)
Calculate the min weight. 
std::vector< std::vector< Real > > 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. 
SPIKING_MNIST 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. 
std::pair< std::vector< std::vector< Real > >, std::vector< uint16_t > > MNIST_DATA
std::vector< size_t > output_sizes
cypress::Population< SpikeSourceArray > create_spike_source(Network &netw, const MNIST_DATA &spikes)
Creates Spike sources in network from spikes. 
std::pair< std::vector< std::vector< std::vector< Real > > >, std::vector< uint16_t > > SPIKING_MNIST
void 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. 
std::vector< size_t > input_sizes
size_t compare_labels(std::vector< uint16_t > &label, std::vector< uint16_t > &res)
Compare original labels with simulation labels, return number of correct labels. 
cypress::Population< SpikeSourceArray > & update_spike_source(cypress::Population< SpikeSourceArray > &source, const MNIST_DATA &spikes)
Update Spike sources in network from spikes. 
std::vector< size_t > size
void 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. 
std::vector< uint16_t > spikes_to_labels(const PopulationBase &pop, Real duration, Real pause, size_t batch_size)
Converts the simulation results into label data. 
Real max_weight(const T &json)
Calculate the max weight, ignore negative values. 
std::vector< std::vector< std::vector< std::vector< Real > > > > CONVOLUTION_FILTER
SPIKING_MNIST 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. 
MNIST_DATA loadMnistData(const size_t num_data, const std::string path)
Read in MNIST data from files. 
std::vector< size_t > input_sizes