(****************************************************************** [LibNN - Neural Networks Library] http://libnn.org Copyright (C) 2002 - 2003 LAGACHERIE Matthieu RICORDEAU Olivier This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Authors: LAGACHERIE Matthieu Paper mail : 7 rue Delescluzes 94280 LE KREMLIN BICETRE, FRANCE E-mail : matthieu@libnn.org RICORDEAU Olivier Paper mail : 69 avenue d'Italie 75013 PARIS, FRANCE E-mail : olivier@libnn.org *****************************************************************) (** The MLPNN virtual class This class is an abstract Multi-Layer Perceptron. @author Matthieu Lagacherie @author Olivier Ricordeau @since 07/10/2003 *) open Nn open DefaultVisitor class mlpNN = object (self : 'a) inherit [('a) defaultVisitor] nn (** The object's dynamic type. *) val _networkType = "MLPNN" (** The output activation 3-dimensional array. Stores the network's neuron's output activation. *) val mutable _outputActivation = [|[|0.0|]|] (** The input sum 3-dimensional array. Stores the network's neuron's input sum. *) val mutable _inputSum = [|[|0.0|]|] (** The error 3-dimensional array. Stores the network's neuron's error term. *) val mutable _error = [|[|0.0|]|] (** The weights 4-dimensional array. Stores the weights of the connections between the neurons. *) val mutable _weights = [|[|[|0.0|]|]|] (** The gradients 4-dimensional array. Stores component of the gradient (for the minimization by gradient decent). *) val mutable _gradients = [|[|[|0.0|]|]|] (** The number of layers in the network. *) val mutable _layerNb = 0 (** The numberof neurones per layer. *) val mutable _neuronsPerLayers = [|0|] (** The generic accept method. *) method accept (visitor : ('a) defaultVisitor) = visitor#visit self (** A get*. @return The output activation 3-dimensional array. *) method getOutputActivation = ref _outputActivation (** A get*. @return The input sum 3-dimensional array. *) method getInputSum = ref _inputSum (** A get*. @return The error sum 3-dimensional array. *) method getError = ref _error (** A get*. @return The weights 4-dimensional array. *) method getWeights = ref _weights (** A get*. @return The gradients 4-dimensional array. *) method getGradients = ref _gradients (** A get*. @return The number of layers in the network. *) method getLayerNb = _layerNb (** A get*. @return The number of neurones per layer in network. *) method getNeuronsPerLayer layer = _neuronsPerLayers.(layer) (** A get*. @return The object's dynamic type. *) method getNetworkType = _networkType (** Sets the output activations array. *) method setOutputActivation outputActivation = _outputActivation <- outputActivation (** Sets the input sums array. *) method setInputSum inputSum = _inputSum <- inputSum (** Sets the errors array. *) method setError error = _error <- error (** Sets the weights array. *) method setWeights weights = _weights <- weights (** Sets the gradients array. *) method setGradients gradients = _gradients <- gradients (** Sets the number of layers. *) method setLayerNb layerNb = _layerNb <- layerNb (** Sets the number of neurons per layer. *) method setNeuronsPerLayer neuronsPerLayers = _neuronsPerLayers <- neuronsPerLayers (** Sets the number of layers. *) method setLayerNb layerNb = _layerNb <- layerNb (** Sets the input activations. *) method setInputActivation inputSumActivation = _inputSum.(0) <- inputSumActivation end