-
Notifications
You must be signed in to change notification settings - Fork 6
/
Network2.h
67 lines (56 loc) · 2.05 KB
/
Network2.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#pragma once
#include "Connection.h"
#include "Neuron.h"
// Enumeration for network encoding types: div+divdot and div place cells
typedef enum EncodingType { BOTH, PLACE } EncodingType;
// Struct that defines a network of one spiking layer
typedef struct Network {
// Encoding type
EncodingType type;
// Decoding scale
float decoding_scale;
// We need place cell centers if we have place cell encoding
float *centers;
// Input, encoded input and output layer sizes
int in_size, in_enc_size, out_size;
// Two input place holders: one for scalar values
// and one for encoded currents (size in_size)
float *in, *in_enc;
// Connection input -> output
Connection *inout;
// Output neurons
Neuron *out;
} Network;
// Struct that holds the configuration of a one-layer network
// To be used when loading parameters from a header file
typedef struct NetworkConf {
// Encoding type
EncodingType const type;
// Decoding scale
float decoding_scale;
// Place cell centers (just BS if we don't use them)
float const *centers;
// Input, encoded input and output layer sizes
int const in_size, in_enc_size, out_size;
// Connection input -> output
ConnectionConf const *inout;
// Output neurons
NeuronConf const *out;
} NetworkConf;
// Build network: calls build functions for children
Network build_network(int const in_size, int const in_enc_size,
int const out_size);
// Init network: calls init functions for children
void init_network(Network *net);
// Reset network: calls reset functions for children
void reset_network(Network *net);
// Load parameters for network from header file and call load functions for
// children
void load_network_from_header(Network *net, NetworkConf const *conf);
// Free allocated memory for network and call free functions for children
void free_network(Network *net);
// Print network parameters (for debugging purposes)
void print_network(Network const *net);
// Forward network and call forward functions for children
// Encoding and decoding inside
float forward_network(Network *net);