Simple artificial neural network written in erlang.
To create neural network you need to write:
NN = ann:create_neural_network(LIST_OF_NUMBERS_OF_NEURONS_IN_EACH_LAYER).
Training set used for training needs to have a form of:
TS = [{ INPUT1, OUTPUT1 },
{ INPUT2, OUTPUT2 },
...
].
% both INPUTx and OUTPUTx should be lists
To train network we write following lines:
NN ! {learn_nb_epochs, NUMBER_OF_EPOCHS, LEARNING_RATE, TRAINING_SET}.
% or
NN ! {learn_until, MAX_ERROR, LEARNING_RATE, TRAINING_SET}.
For a single input prediction use:
NN ! {predict, INPUT}.
For multiple predictions at once use:
ann:predict(NN, [INPUT1, INPUT2, ...]).
% create network
NN = ann:create_neural_network([2, 3, 1]).
The above line of code will create neural network that looks like this:
% create training set
TS = [{ [0, 0], [0] },
{ [0, 1], [1] },
{ [1, 0], [1] },
{ [1, 1], [0] }].
% train network on that set
NN ! {learn_until, 0.00001, 0.1, TS}.
% predict output using network
NN ! {predict, [0, 0]}.
% or
ann:predict(NN, [[0, 0], [0, 1], [1, 0], [1, 1]]).
Example output for multiple predictions in above sample:
[[0.0011777173182934142],
[0.9985160111565027],
[0.9981415398654492],
[0.0016010497083807085]]