GeNN
2.2.3
GPU enhanced Neuronal Networks (GeNN)
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
simulation_synapse_policy_dense.h
Go to the documentation of this file.
1
#pragma once
2
3
// Standard includes
4
#include <functional>
5
#include <numeric>
6
7
//----------------------------------------------------------------------------
8
// SimulationSynapsePolicyDense
9
//----------------------------------------------------------------------------
10
class
SimulationSynapsePolicyDense
11
{
12
public
:
13
//----------------------------------------------------------------------------
14
// Public API
15
//----------------------------------------------------------------------------
16
void
Init
()
17
{
18
// Create array pointing to weights
19
m_TheW[0] = wsyn0;
20
m_TheW[1] = wsyn1;
21
m_TheW[2] = wsyn2;
22
m_TheW[3] = wsyn3;
23
m_TheW[4] = wsyn4;
24
m_TheW[5] = wsyn5;
25
m_TheW[6] = wsyn6;
26
m_TheW[7] = wsyn7;
27
m_TheW[8] = wsyn8;
28
m_TheW[9] = wsyn9;
29
}
30
31
template
<
typename
UpdateFn,
typename
StepGeNNFn>
32
float
Simulate
(UpdateFn updateFn, StepGeNNFn stepGeNNFn)
33
{
34
float
err = 0.0f;
35
float
x[10][100];
36
for
(
int
i = 0; i < (int)(20.0f /
DT
); i++)
37
{
38
// **YUCK** update global time - this shouldn't be user responsibility
39
t = i *
DT
;
40
41
// for each delay
42
for
(
int
d = 0; d < 10; d++)
43
{
44
// for all pre-synaptic neurons
45
for
(
int
j = 0; j < 10; j++)
46
{
47
// for all post-syn neurons
48
for
(
int
k = 0; k < 10; k++)
49
{
50
float
newX;
51
if
(updateFn(d, j, k, t, newX))
52
{
53
x[d][(j * 10) + k] = newX;
54
}
55
else
if
(i == 0)
56
{
57
x[d][(j * 10) + k] = 0.0f;
58
}
59
}
60
}
61
62
// Add error for this time step to total
63
err += std::inner_product(&x[d][0], &x[d][100],
64
GetTheW
(d),
65
0.0f,
66
std::plus<float>(),
67
[](
float
a,
float
b){
return
abs(a - b); });
68
}
69
70
// Step GeNN kernel
71
stepGeNNFn();
72
}
73
74
return
err;
75
}
76
77
protected
:
78
//--------------------------------------------------------------------------
79
// Protected API
80
//--------------------------------------------------------------------------
81
float
*
GetTheW
(
unsigned
int
delay)
const
82
{
83
return
m_TheW[delay];
84
}
85
86
void
SetTheW
(
unsigned
int
i,
unsigned
int
j,
float
value)
87
{
88
m_TheW[i][j] = value;
89
}
90
91
private
:
92
//--------------------------------------------------------------------------
93
// Members
94
//--------------------------------------------------------------------------
95
float
*m_TheW[10];
96
};
SimulationSynapsePolicyDense
Definition:
simulation_synapse_policy_dense.h:10
SimulationSynapsePolicyDense::Simulate
float Simulate(UpdateFn updateFn, StepGeNNFn stepGeNNFn)
Definition:
simulation_synapse_policy_dense.h:32
SimulationSynapsePolicyDense::GetTheW
float * GetTheW(unsigned int delay) const
Definition:
simulation_synapse_policy_dense.h:81
DT
#define DT
This defines the global time step at which the simulation will run.
Definition:
HHVclampGA_project/model/MBody1.cc:21
SimulationSynapsePolicyDense::Init
void Init()
Definition:
simulation_synapse_policy_dense.h:16
SimulationSynapsePolicyDense::SetTheW
void SetTheW(unsigned int i, unsigned int j, float value)
Definition:
simulation_synapse_policy_dense.h:86
tests
utils
simulation_synapse_policy_dense.h
Generated on Tue May 30 2017 12:01:09 for GeNN by
1.8.11