SNABSuite  0.x
Spiking Neural Architecture Benchmark Suite
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SNAB::MnistITL Class Reference

#include <mnist.hpp>

Inheritance diagram for SNAB::MnistITL:
SNAB::MnistITLLastLayer SNAB::MNIST_BASE SNAB::SNABBase

Public Member Functions

 MnistITL (const std::string backend, size_t bench_index)
 
std::shared_ptr< SNABBaseclone () override
 Virtual method cloning the SNAB without knowing which SNAB it is. More...
 
virtual cypress::Network & build_netw (cypress::Network &netw) override
 Building the neural network for benchmarking. If you want to use an external network, you should use the first version of building (and the corresponding run function), for the member network use the second function. The implementation is contained in the first one. More...
 
virtual void run_netw (cypress::Network &netw) override
 
virtual std::vector< std::array< cypress::Real, 4 > > evaluate () override
 This should contain the evaluation process and return the result in order of those in names(), types() and measures(). The array contains in this order: result, standard deviation, minimal value, maximal value. If these are not provided, use NaN() as entry. More...
 
cypress::Network & build ()
 Calls SNABBase::build_netw with the internal network. More...
 
void run ()
 Calls SNABBase::run_netw on the internal network. More...
 
const std::string snab_name () const
 Returns the name of the current benchmark. More...
 
const std::vector< std::string > & indicator_names () const
 Getter for SNABSSuite::m_indicator_names. More...
 
const std::vector< std::string > & indicator_types () const
 Getter for SNABSSuite::m_indicator_types. More...
 
const std::vector< std::string > & indicator_measures () const
 Getter for SNABSSuite::m_indicator_measures. More...
 
cypress::Json evaluate_json ()
 The result of evaluation() is converted into the format used by the HBP benchmark repository. More...
 
cypress::Json get_config () const
 Getter for the config file. More...
 
void set_config (cypress::Json json)
 Setting a new config file. Note that before building the new network you probably want to reset the network structure, because the old populations and results will not be deleted automatically. More...
 
void reset_network ()
 Reset the internal cypress network, therefore deleting all old populations. For example in several concurrent runs with different configurations. More...
 
bool valid () const
 Returns the state of the m_valid flag. Simulation should not be executed when valid() returns false. More...
 

Protected Member Functions

size_t create_deep_network (cypress::Network &netw, Real max_weight=0.0, Real max_pool_weight=0.0, Real pool_inhib_weight=0.0)
 Converts a prepared json to a network. More...
 
void read_config ()
 Read config from m_config. More...
 
cypress::Network & build_netw_int (cypress::Network &netw)
 Build the network, maybe scale down image. More...
 
std::string _debug_filename (const std::string append=std::string()) const
 Beginning of the filename of all debug data (including directories) More...
 

Protected Attributes

std::pair< std::vector< std::vector< std::vector< Real > > >, std::vector< uint16_t > > m_spmnist
 
bool m_positive = false
 
cypress::Real m_norm_rate_hidden = 1.0
 
cypress::Real m_norm_rate_last = 1.0
 
size_t m_global_correct = 0
 
size_t m_num_images = 0
 
cypress::Real m_sim_time = 0
 
std::string m_loss_function = "CatHinge"
 
bool m_last_layer_only = true
 
size_t m_num_test_images = 10000
 
size_t m_test_batchsize = 0
 
NeuronParameter m_neuro_params
 
std::string m_neuron_type_str
 
size_t m_images
 
size_t m_batchsize
 
cypress::Real m_duration
 
cypress::Real m_max_freq
 
cypress::Real m_pause
 
bool m_poisson
 
bool m_train_data
 
cypress::Real m_max_weight
 
cypress::Real m_max_pool_weight
 
cypress::Real m_pool_inhib_weight
 
cypress::Real m_pool_delay
 
std::vector< std::pair< std::vector< std::vector< Real > >, std::vector< uint16_t > > > m_batch_data
 
bool m_batch_parallel = true
 
std::vector< cypress::Network > m_networks
 
std::vector< cypress::PopulationBase > m_label_pops
 
std::string m_dnn_file = ""
 
bool m_scaled_image = false
 
std::shared_ptr< MNIST::MLPBasem_mlp
 
cypress::Real m_weights_scale_factor = 0.0
 
std::vector< cypress::Real > m_conv_weights_scale_factors
 
bool m_count_spikes = false
 
std::vector< cypress::PopulationBase > m_all_pops
 
cypress::Network m_netw
 Internal spiking network which should be used by the SNAB. More...
 
cypress::Json m_config_file
 Platform specific config file which is read in with the constructor. More...
 
std::string m_backend
 String which contains the name of the simulation backend. More...
 
bool m_valid = false
 Flag which tracks whether the SNAB can be executed on the backend This can be set in config file by setting the key "invalid" for the simulator. More...
 
const std::string m_snab_name
 The name of the Benchmark/SNAB. More...
 
const std::vector< std::string > m_indicator_names
 For formatting the output in the correct structure introduced in the SP9 Guidebook, the evaluation process needs the exact order of the names, types and measures of the results returned from the function SNABBase::evaluate(). indicator_names should be unique for the measurement and represent the idea behind the value. More...
 
const std::vector< std::string > m_indicator_types
 indicator_types can be e.g. "quality", "performance", "energy consumption". See also SNABBase::indicator_names. More...
 
const std::vector< std::string > m_indicator_measures
 indicator_measures should be the "type of the measurement", or what has been measures, e.g. norm, p-value, time. See also SNABBase::indicator_names. More...
 
const std::vector< std::string > m_indicator_units
 indicator_units should be the "unit of the measurement", therefore the unit of the value. More...
 
const size_t m_bench_index
 

Detailed Description

This class combines the MNIST benchmark with an hardware in the loop re-training to compensate device mismatch. Here, we train all layers

Definition at line 257 of file mnist.hpp.

Constructor & Destructor Documentation

SNAB::MnistITL::MnistITL ( const std::string  backend,
size_t  bench_index 
)
inline

Definition at line 260 of file mnist.hpp.

261  : MnistITLLastLayer(backend, bench_index, __func__)
262  {
263  m_last_layer_only = false;
264  }
MnistITLLastLayer(const std::string backend, size_t bench_index)
Definition: mnist.hpp:217

Member Function Documentation

std::string SNAB::SNABBase::_debug_filename ( const std::string  append = std::string()) const
protectedinherited

Beginning of the filename of all debug data (including directories)

Returns
std::__cxx11::string "debug/[backend]/[snabname]_"
cypress::Network& SNAB::SNABBase::build ( )
inlineinherited

Calls SNABBase::build_netw with the internal network.

Returns
cypress::Network& Pointer to the constructed network

Definition at line 77 of file snab_base.hpp.

77 { return build_netw(m_netw); };
virtual cypress::Network & build_netw(cypress::Network &network)=0
Building the neural network for benchmarking. If you want to use an external network, you should use the first version of building (and the corresponding run function), for the member network use the second function. The implementation is contained in the first one.
cypress::Network m_netw
Internal spiking network which should be used by the SNAB.
Definition: snab_base.hpp:197
virtual cypress::Network& SNAB::MnistITLLastLayer::build_netw ( cypress::Network &  network)
overridevirtualinherited

Building the neural network for benchmarking. If you want to use an external network, you should use the first version of building (and the corresponding run function), for the member network use the second function. The implementation is contained in the first one.

Parameters
networkExternal network SNAB/benchmark will be constructed in
Returns
cypress::Network& Pointer to the constructed network

Reimplemented from SNAB::MNIST_BASE.

cypress::Network& SNAB::MNIST_BASE::build_netw_int ( cypress::Network &  netw)
protectedinherited

Build the network, maybe scale down image.

Parameters
netwcypress network
Returns
the final network
std::shared_ptr<SNABBase> SNAB::MnistITL::clone ( )
inlineoverridevirtual

Virtual method cloning the SNAB without knowing which SNAB it is.

Reimplemented from SNAB::MnistITLLastLayer.

Definition at line 265 of file mnist.hpp.

266  {
267  return std::make_shared<MnistITL>(m_backend, m_bench_index);
268  }
std::string m_backend
String which contains the name of the simulation backend.
Definition: snab_base.hpp:210
const size_t m_bench_index
Definition: snab_base.hpp:260
size_t SNAB::MNIST_BASE::create_deep_network ( cypress::Network &  netw,
Real  max_weight = 0.0,
Real  max_pool_weight = 0.0,
Real  pool_inhib_weight = 0.0 
)
protectedinherited

Converts a prepared json to a network.

Parameters
datadata of the network. The repo provides a python script to create a compatible json file
netwnetwork object in which the deep network will be created
Returns
number of layers
virtual std::vector<std::array<cypress::Real, 4> > SNAB::MnistITLLastLayer::evaluate ( )
overridevirtualinherited

This should contain the evaluation process and return the result in order of those in names(), types() and measures(). The array contains in this order: result, standard deviation, minimal value, maximal value. If these are not provided, use NaN() as entry.

Reimplemented from SNAB::MNIST_BASE.

cypress::Json SNAB::SNABBase::evaluate_json ( )
inherited

The result of evaluation() is converted into the format used by the HBP benchmark repository.

Returns
cypress::Json Benchmark results
cypress::Json SNAB::SNABBase::get_config ( ) const
inlineinherited

Getter for the config file.

Returns
cypress::Json config file

Definition at line 154 of file snab_base.hpp.

154 { return m_config_file; }
cypress::Json m_config_file
Platform specific config file which is read in with the constructor.
Definition: snab_base.hpp:204
const std::vector<std::string>& SNAB::SNABBase::indicator_measures ( ) const
inlineinherited

Getter for SNABSSuite::m_indicator_measures.

Returns
const std::vector< std::__cxx11::string >& list of benchmark indicator measures (their unit)

Definition at line 128 of file snab_base.hpp.

129  {
130  return m_indicator_measures;
131  }
const std::vector< std::string > m_indicator_measures
indicator_measures should be the "type of the measurement", or what has been measures, e.g. norm, p-value, time. See also SNABBase::indicator_names.
Definition: snab_base.hpp:244
const std::vector<std::string>& SNAB::SNABBase::indicator_names ( ) const
inlineinherited

Getter for SNABSSuite::m_indicator_names.

Returns
const std::vector< std::__cxx11::string >& list of benchmark indicator names

Definition at line 106 of file snab_base.hpp.

107  {
108  return m_indicator_names;
109  }
const std::vector< std::string > m_indicator_names
For formatting the output in the correct structure introduced in the SP9 Guidebook, the evaluation process needs the exact order of the names, types and measures of the results returned from the function SNABBase::evaluate(). indicator_names should be unique for the measurement and represent the idea behind the value.
Definition: snab_base.hpp:231
const std::vector<std::string>& SNAB::SNABBase::indicator_types ( ) const
inlineinherited

Getter for SNABSSuite::m_indicator_types.

Returns
const std::vector< std::__cxx11::string >& list of benchmark indicator types

Definition at line 117 of file snab_base.hpp.

118  {
119  return m_indicator_types;
120  }
const std::vector< std::string > m_indicator_types
indicator_types can be e.g. "quality", "performance", "energy consumption". See also SNABBase::indica...
Definition: snab_base.hpp:237
void SNAB::MNIST_BASE::read_config ( )
protectedinherited

Read config from m_config.

void SNAB::SNABBase::reset_network ( )
inlineinherited

Reset the internal cypress network, therefore deleting all old populations. For example in several concurrent runs with different configurations.

Definition at line 170 of file snab_base.hpp.

170 { m_netw = cypress::Network(); }
cypress::Network m_netw
Internal spiking network which should be used by the SNAB.
Definition: snab_base.hpp:197
void SNAB::SNABBase::run ( )
inlineinherited

Calls SNABBase::run_netw on the internal network.

Definition at line 91 of file snab_base.hpp.

91 { run_netw(m_netw); };
cypress::Network m_netw
Internal spiking network which should be used by the SNAB.
Definition: snab_base.hpp:197
virtual void run_netw(cypress::Network &network)=0
virtual void SNAB::MnistITLLastLayer::run_netw ( cypress::Network &  network)
overridevirtualinherited

Execution of the benchmark on the simulation platform. Similar to the build function, the first function contains the implementation, while the second simply uses the first with member networks.

Parameters
networkExternal network SNAB/benchmark will be constructed in

Reimplemented from SNAB::MNIST_BASE.

void SNAB::SNABBase::set_config ( cypress::Json  json)
inlineinherited

Setting a new config file. Note that before building the new network you probably want to reset the network structure, because the old populations and results will not be deleted automatically.

Parameters
jsonnew config

Definition at line 163 of file snab_base.hpp.

163 { m_config_file = json; }
cypress::Json m_config_file
Platform specific config file which is read in with the constructor.
Definition: snab_base.hpp:204
const std::string SNAB::SNABBase::snab_name ( ) const
inlineinherited

Returns the name of the current benchmark.

Returns
const std::__cxx11::string Name of the current benchmark

Definition at line 98 of file snab_base.hpp.

98 { return m_snab_name; }
const std::string m_snab_name
The name of the Benchmark/SNAB.
Definition: snab_base.hpp:222
bool SNAB::SNABBase::valid ( ) const
inlineinherited

Returns the state of the m_valid flag. Simulation should not be executed when valid() returns false.

Returns
bool True when benchmark is valid for execution

Definition at line 179 of file snab_base.hpp.

179 { return m_valid; }
bool m_valid
Flag which tracks whether the SNAB can be executed on the backend This can be set in config file by s...
Definition: snab_base.hpp:217

Member Data Documentation

std::vector<cypress::PopulationBase> SNAB::MNIST_BASE::m_all_pops
protectedinherited

Definition at line 81 of file mnist.hpp.

std::string SNAB::SNABBase::m_backend
protectedinherited

String which contains the name of the simulation backend.

Definition at line 210 of file snab_base.hpp.

std::vector< std::pair<std::vector<std::vector<Real> >, std::vector<uint16_t> > > SNAB::MNIST_BASE::m_batch_data
protectedinherited

Definition at line 64 of file mnist.hpp.

bool SNAB::MNIST_BASE::m_batch_parallel = true
protectedinherited

Definition at line 66 of file mnist.hpp.

size_t SNAB::MNIST_BASE::m_batchsize
protectedinherited

Definition at line 50 of file mnist.hpp.

const size_t SNAB::SNABBase::m_bench_index
protectedinherited

Definition at line 260 of file snab_base.hpp.

cypress::Json SNAB::SNABBase::m_config_file
protectedinherited

Platform specific config file which is read in with the constructor.

Definition at line 204 of file snab_base.hpp.

std::vector<cypress::Real> SNAB::MNIST_BASE::m_conv_weights_scale_factors
protectedinherited

Definition at line 78 of file mnist.hpp.

bool SNAB::MNIST_BASE::m_count_spikes = false
protectedinherited

Definition at line 80 of file mnist.hpp.

std::string SNAB::MNIST_BASE::m_dnn_file = ""
protectedinherited

Definition at line 73 of file mnist.hpp.

cypress::Real SNAB::MNIST_BASE::m_duration
protectedinherited

Definition at line 51 of file mnist.hpp.

size_t SNAB::MnistITLLastLayer::m_global_correct = 0
protectedinherited

Definition at line 244 of file mnist.hpp.

size_t SNAB::MNIST_BASE::m_images
protectedinherited

Definition at line 50 of file mnist.hpp.

const std::vector<std::string> SNAB::SNABBase::m_indicator_measures
protectedinherited

indicator_measures should be the "type of the measurement", or what has been measures, e.g. norm, p-value, time. See also SNABBase::indicator_names.

Definition at line 244 of file snab_base.hpp.

const std::vector<std::string> SNAB::SNABBase::m_indicator_names
protectedinherited

For formatting the output in the correct structure introduced in the SP9 Guidebook, the evaluation process needs the exact order of the names, types and measures of the results returned from the function SNABBase::evaluate(). indicator_names should be unique for the measurement and represent the idea behind the value.

Definition at line 231 of file snab_base.hpp.

const std::vector<std::string> SNAB::SNABBase::m_indicator_types
protectedinherited

indicator_types can be e.g. "quality", "performance", "energy consumption". See also SNABBase::indicator_names.

Definition at line 237 of file snab_base.hpp.

const std::vector<std::string> SNAB::SNABBase::m_indicator_units
protectedinherited

indicator_units should be the "unit of the measurement", therefore the unit of the value.

Definition at line 250 of file snab_base.hpp.

std::vector<cypress::PopulationBase> SNAB::MNIST_BASE::m_label_pops
protectedinherited

Definition at line 71 of file mnist.hpp.

bool SNAB::MnistITLLastLayer::m_last_layer_only = true
protectedinherited

Definition at line 248 of file mnist.hpp.

std::string SNAB::MnistITLLastLayer::m_loss_function = "CatHinge"
protectedinherited

Definition at line 247 of file mnist.hpp.

cypress::Real SNAB::MNIST_BASE::m_max_freq
protectedinherited

Definition at line 51 of file mnist.hpp.

cypress::Real SNAB::MNIST_BASE::m_max_pool_weight
protectedinherited

Definition at line 58 of file mnist.hpp.

cypress::Real SNAB::MNIST_BASE::m_max_weight
protectedinherited

Definition at line 56 of file mnist.hpp.

std::shared_ptr<MNIST::MLPBase> SNAB::MNIST_BASE::m_mlp
protectedinherited

Definition at line 75 of file mnist.hpp.

cypress::Network SNAB::SNABBase::m_netw
protectedinherited

Internal spiking network which should be used by the SNAB.

Definition at line 197 of file snab_base.hpp.

std::vector<cypress::Network> SNAB::MNIST_BASE::m_networks
protectedinherited

Definition at line 69 of file mnist.hpp.

NeuronParameter SNAB::MNIST_BASE::m_neuro_params
protectedinherited

Definition at line 48 of file mnist.hpp.

std::string SNAB::MNIST_BASE::m_neuron_type_str
protectedinherited

Definition at line 49 of file mnist.hpp.

cypress::Real SNAB::MnistITLLastLayer::m_norm_rate_hidden = 1.0
protectedinherited

Definition at line 242 of file mnist.hpp.

cypress::Real SNAB::MnistITLLastLayer::m_norm_rate_last = 1.0
protectedinherited

Definition at line 243 of file mnist.hpp.

size_t SNAB::MnistITLLastLayer::m_num_images = 0
protectedinherited

Definition at line 245 of file mnist.hpp.

size_t SNAB::MnistITLLastLayer::m_num_test_images = 10000
protectedinherited

Definition at line 249 of file mnist.hpp.

cypress::Real SNAB::MNIST_BASE::m_pause
protectedinherited

Definition at line 51 of file mnist.hpp.

bool SNAB::MNIST_BASE::m_poisson
protectedinherited

Definition at line 54 of file mnist.hpp.

cypress::Real SNAB::MNIST_BASE::m_pool_delay
protectedinherited

Definition at line 60 of file mnist.hpp.

cypress::Real SNAB::MNIST_BASE::m_pool_inhib_weight
protectedinherited

Definition at line 59 of file mnist.hpp.

bool SNAB::MnistITLLastLayer::m_positive = false
protectedinherited

Definition at line 241 of file mnist.hpp.

bool SNAB::MNIST_BASE::m_scaled_image = false
protectedinherited

Definition at line 74 of file mnist.hpp.

cypress::Real SNAB::MnistITLLastLayer::m_sim_time = 0
protectedinherited

Definition at line 246 of file mnist.hpp.

const std::string SNAB::SNABBase::m_snab_name
protectedinherited

The name of the Benchmark/SNAB.

Definition at line 222 of file snab_base.hpp.

std::pair<std::vector<std::vector<std::vector<Real> > >, std::vector<uint16_t> > SNAB::MnistITLLastLayer::m_spmnist
protectedinherited

Definition at line 239 of file mnist.hpp.

size_t SNAB::MnistITLLastLayer::m_test_batchsize = 0
protectedinherited

Definition at line 250 of file mnist.hpp.

bool SNAB::MNIST_BASE::m_train_data
protectedinherited

Definition at line 54 of file mnist.hpp.

bool SNAB::SNABBase::m_valid = false
protectedinherited

Flag which tracks whether the SNAB can be executed on the backend This can be set in config file by setting the key "invalid" for the simulator.

Definition at line 217 of file snab_base.hpp.

cypress::Real SNAB::MNIST_BASE::m_weights_scale_factor = 0.0
protectedinherited

Definition at line 77 of file mnist.hpp.


The documentation for this class was generated from the following file: