Train and run a neural network in OCaml.
This implements a feed-forward, multi-layered and fully-connected network. Network learning is implemented as gradient descent using backpropagation algorithm.
Two methods are exposed (neuralnet.mli):
Neuralnet.fit - returns a trained neural network and expects the following arguments:
dataset- list of tuples(input, output)where input/output arefloatarraysalg_type- optional. Gradient descent type:Batch,StohasticorMiniBatch. Defaults toBatch.layers- optional. List of sizes of hidden layers in the network. Defaults to[](no hidden layers).activation- optional. Activation function to be used. Defaults toActivation.sigmoid.max_iter- optional. Run the gradient descent up tomax_iteriterations. Defaults to10000.eps- optional. Run the gradient descent until learning error reacheseps. Defaults to1e-3.rate- optional. Coefficient to multiply gradients with when updating weights. Defaults to0.2.verbose- optional. Learning errors through iterations will be printed tostderrif set totrue. Defaults tofalse.
Neuralnet.predict - runs the input through the network and returns the output. Expects following arguments:
net- trained neural network. The thingNeuralnet.fitreturns.x- an input to the network.
See example.ml.
To run it do:
make
./example