-
Notifications
You must be signed in to change notification settings - Fork 6
/
Connection.h
43 lines (35 loc) · 1.35 KB
/
Connection.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once
// Struct that defines a connection between two layers of neurons
typedef struct Connection {
// Connection shape: (post, pre)
int post, pre;
// Connection weights
// Use a 1D array, since structs don't support variable-sized arrays
// TODO: is this the best way to go? Would like to be able to do w[i][j]
// Check this with Erik
float *w;
} Connection;
// Struct that holds the configuration (weights) of a connection
// To be used when loading parameters from a header file
typedef struct ConnectionConf {
// Connection shape: (post, pre)
int const post, pre;
// Connection weights (1D array)
// TODO: or actual weight array? Might be easier to specify in conf header..
float const *w;
} ConnectionConf;
// Build connection
Connection build_connection(int const post, int const pre);
// Init connection
void init_connection(Connection *c);
// Reset connection
// Doesn't actually do anything, just for consistency
void reset_connection(Connection *c);
// Load parameters (weights) for connection from header file
// (using the ConnectionConf struct)
void load_connection_from_header(Connection *c, ConnectionConf const *conf);
// Free allocated memory for connection
void free_connection(Connection *c);
// Forward
// Spikes as floats to deal with real-valued inputs
void forward_connection(Connection *c, float x[], float const s[]);