-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnn.h
More file actions
63 lines (44 loc) · 921 Bytes
/
nn.h
File metadata and controls
63 lines (44 loc) · 921 Bytes
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
#ifndef NN_H
#define NN_H
#include "engine.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef void (*zero_grad)(void* self);
typedef Value** (*get_parmeters)(void* self);
typedef struct
{
zero_grad zero_grad;
get_parmeters parmeters;
} Module;
typedef struct
{
Module base;
Value** weights;
Value* bias;
int nin;
int nonlin;
} Neuron;
typedef struct
{
Module base;
Neuron** neurons;
int nout;
int nin;
} Layer;
typedef struct
{
Module base;
Layer** layers;
int n_layers;
} MLP;
void free_neuron(Neuron* n);
Neuron* create_neuron(int nin, int nonlin);
Value* call_neuron(Neuron* self, Value** x);
Layer* create_layer(int nin, int nout, int nonlin);
void free_layer(Layer* layer);
Value** call_layer(Layer* layer, Value** x);
MLP* create_mlp(int nin, int* nouts, int n_layers);
Value** call_mlp(MLP* self, Value** x);
void free_mlp(MLP* mlp);
#endif // !NN_H