SNABSuite  0.x
Spiking Neural Architecture Benchmark Suite
wta_like.hpp
Go to the documentation of this file.
1 /*
2  * SNABSuite -- Spiking Neural Architecture Benchmark Suite
3  * Copyright (C) 2018 Christoph Ostrau
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 #ifndef SNABSUITE_SNABS_WTA_HPP
22 #define SNABSUITE_SNABS_WTA_HPP
23 
24 #include <cypress/cypress.hpp>
25 
26 #include <vector>
27 
28 #include "common/snab_base.hpp"
29 
30 namespace SNAB {
31 using namespace cypress;
32 
37 class SimpleWTA : public SNABBase {
38 private:
39  std::vector<cypress::PopulationBase> m_pop;
40  std::vector<cypress::Population<cypress::SpikeSourcePoisson>> m_pop_source;
41  size_t m_num_neurons_pop = 0, m_num_source_neurons = 0;
42  cypress::Real m_firing_rate;
43  NeuronParameter m_neuro_params;
44  cypress::Real m_simulation_length = 10000; // ms
45  cypress::Real m_bin_size = 15.0; // ms
46 
47  // Network parameters
48  cypress::Real m_weight_inp = 0, m_delay = 1.0, m_weight_self = 0.0,
49  m_weight_inh = 0.0;
50  cypress::Real m_prob_inp = 0, m_prob_self = 0.0, m_prob_inh = 0.0;
51 
52 public:
53  SimpleWTA(std::string backend, size_t bench_index);
54  cypress::Network &build_netw(cypress::Network &netw) override;
55  void run_netw(cypress::Network &netw) override;
56  std::vector<std::array<cypress::Real, 4>> evaluate() override;
57 
58  std::shared_ptr<SNABBase> clone() override
59  {
60  return std::make_shared<SimpleWTA>(m_backend, m_bench_index);
61  }
62 
71  static std::vector<Real> calculate_WTA_metrics(
72  const std::vector<size_t> &bins, const std::vector<size_t> &bins2,
73  const Real bin_size);
74 };
75 
80 class LateralInhibWTA : public SNABBase {
81 private:
82  std::vector<cypress::PopulationBase> m_pop;
83  std::vector<cypress::Population<cypress::SpikeSourcePoisson>> m_pop_source;
84  cypress::PopulationBase m_inhibit_pop;
85  size_t m_num_neurons_pop = 0, m_num_source_neurons = 0,
86  m_num_inhibitory_neurons = 0;
87  cypress::Real m_firing_rate;
88  NeuronParameter m_neuro_params;
89  cypress::Real m_simulation_length = 10000; // ms
90  cypress::Real m_bin_size = 15.0; // ms
91 
92  // Network parameters
93  cypress::Real m_weight_inp = 0, m_delay = 1.0, m_weight_self = 0.0,
94  m_weight_lat_inh = 0.0, m_weight_lat_exc = 0.0;
95  cypress::Real m_prob_inp = 0, m_prob_self = 0.0, m_prob_lat_exc = 0.0;
96 
97 public:
98  LateralInhibWTA(std::string backend, size_t bench_index);
99  cypress::Network &build_netw(cypress::Network &network) override;
100  void run_netw(cypress::Network &network) override;
101  std::vector<std::array<cypress::Real, 4>> evaluate() override;
102 
103  std::shared_ptr<SNABBase> clone() override
104  {
105  return std::make_shared<LateralInhibWTA>(m_backend, m_bench_index);
106  }
107 };
108 
113 class MirrorInhibWTA : public SNABBase {
114 private:
115  std::vector<cypress::PopulationBase> m_pop;
116  std::vector<cypress::Population<cypress::SpikeSourcePoisson>> m_pop_source;
117  std::vector<cypress::PopulationBase> m_inhibit_pop;
118  size_t m_num_neurons_pop = 0, m_num_source_neurons = 0,
119  m_num_inhibitory_neurons = 0;
120  cypress::Real m_firing_rate;
121  NeuronParameter m_neuro_params;
122  cypress::Real m_simulation_length = 10000; // ms
123  cypress::Real m_bin_size = 15.0; // ms
124 
125  // Network parameters
126  cypress::Real m_weight_inp = 0, m_delay = 1.0, m_weight_self = 0.0,
127  m_weight_to_inh = 0.0, m_weight_from_inh = 0.0;
128  cypress::Real m_prob_inp = 0, m_prob_self = 0.0, m_prob_to_inh = 0.0;
129 
130 public:
131  MirrorInhibWTA(std::string backend, size_t bench_index);
132  cypress::Network &build_netw(cypress::Network &network) override;
133  void run_netw(cypress::Network &network) override;
134  std::vector<std::array<cypress::Real, 4>> evaluate() override;
135  std::shared_ptr<SNABBase> clone() override
136  {
137  return std::make_shared<MirrorInhibWTA>(m_backend, m_bench_index);
138  }
139 };
140 } // namespace SNAB
141 
142 #endif /* SNABSUITE_SNABS_WTA_HPP */
std::shared_ptr< SNABBase > clone() override
Virtual method cloning the SNAB without knowing which SNAB it is.
Definition: wta_like.hpp:58
std::shared_ptr< SNABBase > clone() override
Virtual method cloning the SNAB without knowing which SNAB it is.
Definition: wta_like.hpp:103
Virtual Base class for SNABs(Benchmarks). All SNABs should have seperate building of networks...
Definition: snab_base.hpp:33
std::shared_ptr< SNABBase > clone() override
Virtual method cloning the SNAB without knowing which SNAB it is.
Definition: wta_like.hpp:135