Neural net library written in C, no dependencies.
$ make install
Remember to add the header cerebellum.h
and link with -lcerebellum
To get started, create an empty net_t
and give it
- The number of layers
- An array with the number of nodes in each layer
- The learning rate
Optionally provide function pointers to initialize the weights and biases.
Example: A 3 layer network with learning rate 0.2
size_t layers[] = { 4, 11, 2 };
net_t net3layer = { .layers = layers, .nlayers = 3, .rate = 0.2 };
initNet(&net3layer, NULL, NULL);
Or you can import a network from a file:
net_t importedNet;
netFromFile(&importedNet, "someNetworkFile");
To feed forward the network, simply provide an input array of equal length to the first layer:
double input[4] = { 0, 0.42, 0.9, 0.1 };
feedforward(&net3layer, input);
To train the network, provide an input as before and the expected output (of size equal to the last layer).
feedforward
must be called before train
for it to be meaningful.
double output[2] = { 0, 1 };
train(&net3layer, input, output);
If the network was initialized using netFromFile
, free the layers array.
Finally call delNet
.
free(importedNet.layers);
delNet(&importedNet);
If you want to save the network before cleaning up, call saveNet
:
saveNet(&net3layer, "networkSaveFile");
delNet(&net3layer);
- Fix dropout
- Add Convolutional Nets
- Add Recurrent Nets
- More ...