SNABSuite  0.x
Spiking Neural Architecture Benchmark Suite
Classes | Functions
SNAB Namespace Reference

Classes

class  BenchmarkExec
 
class  GroupMaxFreqToGroup
 
class  GroupMaxFreqToGroupAllToAll
 
class  GroupMaxFreqToGroupProb
 
class  LateralInhibWTA
 
class  MaxInputAllToAll
 
class  MaxInputFixedInConnector
 
class  MaxInputFixedOutConnector
 
class  MaxInputOneToOne
 
class  MirrorInhibWTA
 
class  MNIST_BASE
 
class  MnistCNNPool
 
class  MnistDiehl
 
class  MnistDoubleCNN
 
class  MnistITL
 
class  MnistITLLastLayer
 
class  MnistNAS129
 
class  MnistNAS63
 
class  MnistNAStop
 
class  MnistSpikey
 
class  OutputFrequencyMultipleNeurons
 
class  OutputFrequencySingleNeuron
 
class  OutputFrequencySingleNeuron2
 
class  ParameterSweep
 
class  RateBasedWeightDependentActivation
 
class  RefractoryPeriod
 
class  SetupTimeAllToAll
 
class  SetupTimeOneToOne
 
class  SetupTimeRandom
 
class  SimpleWTA
 
class  SingleMaxFreqToGroup
 
class  SNABBase
 Virtual Base class for SNABs(Benchmarks). All SNABs should have seperate building of networks, execution and an evaluation tasks. More...
 
class  Utilities
 Collection of usefull Utilities not directly related to spiking networks. More...
 
class  WeightDependentActivation
 

Functions

cypress::Real NaN ()
 Used to indicate bad or invalid results. More...
 
std::vector< std::shared_ptr< SNABBase > > snab_registry (std::string backend, size_t bench_index)
 
template<typename T >
std::map< std::string, T > json_to_map (const cypress::Json &obj)
 
template<typename T >
std::vector< T > read_check (std::map< std::string, T > &input, const std::vector< std::string > &names, const std::vector< T > &defaults)
 
cypress::Json read_config (const std::string &name, const std::string &backend)
 
bool check_json_for_parameters (const std::vector< std::string > &parameters, const cypress::Json &json, const std::string name)
 
cypress::Json extract_backend (const cypress::Json &config, const std::string &backend)
 
template<typename T >
std::vector< T > json_array_to_vector (const cypress::Json &json)
 
template<typename T , int n>
std::array< T, n > json_array_to_array (const cypress::Json &json)
 
template<typename T >
std::vector< std::vector< T > > json_2Darray_to_vector (const cypress::Json &json)
 
template<typename T , int n>
std::vector< std::vector< std::array< T, n > > > json_3Darray_to_vector (const cypress::Json &json)
 
bool replace_arrays_by_value (cypress::Json &json, const size_t &index=0, std::string name="", bool warn=true)
 

Function Documentation

bool SNAB::check_json_for_parameters ( const std::vector< std::string > &  parameters,
const cypress::Json &  json,
const std::string  name 
)
cypress::Json SNAB::extract_backend ( const cypress::Json &  config,
const std::string &  backend 
)

Extract backend specific part from a configuration file. Checks for dot seperated backends

template<typename T >
std::vector<std::vector<T> > SNAB::json_2Darray_to_vector ( const cypress::Json &  json)

Function to convert a two dimensional array to a vector.

Parameters
json2D array to be converted. This should not be an object!
Returns
Vector of vectors of type T containing values of the 2D array

Definition at line 150 of file read_json.hpp.

151 {
152  if (!json.is_array() || !json[0].is_array()) {
153  throw std::invalid_argument("Error in conversion from Json to array!");
154  }
155  std::vector<std::vector<T>> res;
156  for (auto i : json) {
157  res.push_back(json_array_to_vector<T>(i));
158  }
159  return res;
160 }
template<typename T , int n>
std::vector<std::vector<std::array<T, n> > > SNAB::json_3Darray_to_vector ( const cypress::Json &  json)

Function to convert a three dimensional array to a vector.

Parameters
json3D array to be converted. This should not be an object!
Returns
Vector of vectors of type T containing values of the 2D array

Definition at line 168 of file read_json.hpp.

169 {
170  if (!json.is_array() || !json[0].is_array()) {
171  throw std::invalid_argument("Error in conversion from Json to array!");
172  }
173  std::vector<std::vector<std::array<T, n>>> res;
174  for (size_t i = 0; i< json.size(); i++) {
175  std::vector<std::array<T, n>> res2;
176  for (size_t j = 0; j< json[i].size(); j++) {
177  res2.push_back(json_array_to_array<T, n>(json[i][j]));
178  }
179  res.push_back(res2);
180  }
181  return res;
182 }
template<typename T , int n>
std::array<T, n> SNAB::json_array_to_array ( const cypress::Json &  json)

Function to convert a JSON array to a array. This is used for one dimensional arrays only!

Parameters
jsonarray to be converted. This should not be an object!
Returns
Vector of type T containing values of the array

Definition at line 125 of file read_json.hpp.

126 {
127  if (!json.is_array() || json.size() == 0 || json[0].is_array()) {
128  throw std::invalid_argument("Error in conversion from Json to array!");
129  }
130  std::array<T, n> res;
131  size_t index = 0;
132  for (auto i : json) {
133  if (i.is_null()) {
134  res[index] = std::numeric_limits<T>::quiet_NaN();
135  }
136  else {
137  res[index] = T(i);
138  }
139  index ++;
140  }
141  return res;
142 }
template<typename T >
std::vector<T> SNAB::json_array_to_vector ( const cypress::Json &  json)

Function to convert a JSON array to a vector. This is used for one dimensional arrays only!

Parameters
jsonarray to be converted. This shouold not be an object!
Returns
Vector of type T containing values of the array

Definition at line 101 of file read_json.hpp.

102 {
103  if (!json.is_array() || json.size() == 0 || json[0].is_array()) {
104  throw std::invalid_argument("Error in conversion from Json to array!");
105  }
106  std::vector<T> res;
107  for (auto i : json) {
108  if (i.is_null()) {
109  res.push_back(std::numeric_limits<T>::quiet_NaN());
110  }
111  else {
112  res.push_back(T(i));
113  }
114  }
115  return res;
116 }
template<typename T >
std::map<std::string, T> SNAB::json_to_map ( const cypress::Json &  obj)

Store input form json in a map to check everything!

Definition at line 38 of file read_json.hpp.

39 {
40  std::map<std::string, T> input;
41  for (auto i = obj.begin(); i != obj.end(); i++) {
42  const cypress::Json value = i.value();
43  // Suppress entries like Neuron_Type and sub-lists
44  if (value.is_number()) {
45  input.emplace(i.key(), value);
46  }
47  }
48  return input;
49 }
cypress::Real SNAB::NaN ( )

Used to indicate bad or invalid results.

template<typename T >
std::vector<T> SNAB::read_check ( std::map< std::string, T > &  input,
const std::vector< std::string > &  names,
const std::vector< T > &  defaults 
)

Checks if all values given are needed, terminate if not. If a needed value is not given, take default value and warn user

Definition at line 56 of file read_json.hpp.

59 {
60  std::vector<T> res(names.size());
61  for (size_t i = 0; i < res.size(); i++) {
62  auto it = input.find(names[i]);
63  if (it != input.end()) {
64  res[i] = it->second;
65  input.erase(it);
66  }
67  else {
68  res[i] = defaults.at(i);
69  global_logger().debug("SNABSuite",
70  "For " + names[i] + " the default value " +
71  std::to_string(defaults[i]) + " is used");
72  }
73  }
74  for (auto elem : input) {
75  throw std::invalid_argument("Unknown parameter \"" + elem.first + "\"");
76  }
77 
78  return res;
79 }
cypress::Json SNAB::read_config ( const std::string &  name,
const std::string &  backend 
)
bool SNAB::replace_arrays_by_value ( cypress::Json &  json,
const size_t &  index = 0,
std::string  name = "",
bool  warn = true 
)

Replaces all arrays in a json object with one entry of the same array

Parameters
jsonobject to be manipulated
indexindex of value used
warnWhen set to true, warning is given when nothing has been replaced
Returns
true if json was changed
std::vector<std::shared_ptr<SNABBase> > SNAB::snab_registry ( std::string  backend,
size_t  bench_index 
)

A vector containing all SNABs/benchmarks which should be executed. The shared pointer ensures that objects live 'long enough'