marf.Classification.NeuralNetwork
Class NeuralNetwork

java.lang.Object
  extended bymarf.Classification.Classification
      extended bymarf.Classification.NeuralNetwork.NeuralNetwork
All Implemented Interfaces:
StorageManager

public class NeuralNetwork
extends Classification

Class NeuralNetwork

$Header: /cvsroot/marf/marf/src/marf/Classification/NeuralNetwork/NeuralNetwork.java,v 1.30 2004/04/20 16:38:18 mokhov Exp $

Author:
Ian Clement

Field Summary
static int DEFAULT_EPOCH_NUMBER
          Default number of epoch iterations of 64 if none supplied
static double DEFAULT_MIN_ERROR
          Default minimum training error of 0.1 if none supplied
static int DEFAULT_OUTPUT_NEURON_BITS
          How many binary Neurons in the output layer.
static double DEFAULT_TRAINING_CONSTANT
          Default training constant of 1 if none supplied
(package private) static java.lang.String JAXP_SCHEMA_LANGUAGE
          JAXP 1.2 Schema
(package private) static java.lang.String JAXP_SCHEMA_SOURCE
          JAXP 1.2 Schem URL
(package private) static java.lang.String outputEncoding
          All output will use this encoding
(package private) static java.lang.String W3C_XML_SCHEMA
          XML 2001 Schema
 
Fields inherited from class marf.Classification.Classification
oFeatureExtraction, oResult, oTrainingSet
 
Fields inherited from interface marf.Storage.StorageManager
DUMP_BINARY, DUMP_CSV_TEXT, DUMP_GZIP_BINARY, DUMP_XML
 
Constructor Summary
NeuralNetwork(FeatureExtraction poFeatureExtraction)
          NeuralNetwork Constructor
 
Method Summary
 boolean classify()
          Neural Network implementation of classification routine
 void commit()
          Applies changes made to neurons on every net's layer
 void dump()
          Dumps Neural Net to an XML file
 void dumpXML(java.lang.String filename)
          Dumps Neural Network as XML file
 void generate(int piNumOfInputs, int[] paiHiddenLayers, int piNumOfOutputs)
          Generates virgin net at random.
 double[] getRes()
          Gets outputs of a neural network run
static void indent(java.io.BufferedWriter bw, int n)
          Indents the output according to the requested tabulation.
 void initialize(java.lang.String filename, boolean dtd)
          Parses XML and produces NNet.
 void restore()
          Restores Neural Net from an XML file
 boolean train()
          Implementes training of Neural Net
 void train(double[] in, int expected, double trainconst)
          Actual training of the net
 
Methods inherited from class marf.Classification.Classification
getResult
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_OUTPUT_NEURON_BITS

public static final int DEFAULT_OUTPUT_NEURON_BITS
How many binary Neurons in the output layer. Presumably int (our ID) is 4 bytes, hence 4 * 8 = 32 bits, and so many outputs

See Also:
Constant Field Values

DEFAULT_TRAINING_CONSTANT

public static final double DEFAULT_TRAINING_CONSTANT
Default training constant of 1 if none supplied

See Also:
Constant Field Values

DEFAULT_EPOCH_NUMBER

public static final int DEFAULT_EPOCH_NUMBER
Default number of epoch iterations of 64 if none supplied

See Also:
Constant Field Values

DEFAULT_MIN_ERROR

public static final double DEFAULT_MIN_ERROR
Default minimum training error of 0.1 if none supplied

See Also:
Constant Field Values

outputEncoding

static final java.lang.String outputEncoding
All output will use this encoding

See Also:
Constant Field Values

JAXP_SCHEMA_LANGUAGE

static final java.lang.String JAXP_SCHEMA_LANGUAGE
JAXP 1.2 Schema

See Also:
Constant Field Values

W3C_XML_SCHEMA

static final java.lang.String W3C_XML_SCHEMA
XML 2001 Schema

See Also:
Constant Field Values

JAXP_SCHEMA_SOURCE

static final java.lang.String JAXP_SCHEMA_SOURCE
JAXP 1.2 Schem URL

See Also:
Constant Field Values
Constructor Detail

NeuralNetwork

public NeuralNetwork(FeatureExtraction poFeatureExtraction)
NeuralNetwork Constructor

Parameters:
poFeatureExtraction - FeatureExtraction module reference
Method Detail

train

public final boolean train()
                    throws ClassificationException
Implementes training of Neural Net

Overrides:
train in class Classification
Returns:
true
Throws:
ClassificationException

classify

public final boolean classify()
                       throws ClassificationException
Neural Network implementation of classification routine

Specified by:
classify in class Classification
Returns:
true
Throws:
ClassificationException

initialize

public final void initialize(java.lang.String filename,
                             boolean dtd)
                      throws java.io.IOException
Parses XML and produces NNet.

Throws:
java.io.IOException

getRes

public double[] getRes()
Gets outputs of a neural network run

Returns:
array of doubles

indent

public static final void indent(java.io.BufferedWriter bw,
                                int n)
                         throws java.io.IOException
Indents the output according to the requested tabulation. For pretty indentation

Parameters:
bw - Writer object
n - number of tabs
Throws:
java.io.IOException

dumpXML

public final void dumpXML(java.lang.String filename)
                   throws java.io.IOException
Dumps Neural Network as XML file

Parameters:
filename - XML file name to write to
Throws:
java.io.IOException

generate

public final void generate(int piNumOfInputs,
                           int[] paiHiddenLayers,
                           int piNumOfOutputs)
                    throws ClassificationException
Generates virgin net at random.

Parameters:
piNumOfInputs - number of input Neurons in the input layer
paiHiddenLayers - arrays of numbers of Neurons in the hidden layers
piNumOfOutputs - number of output Neurons in the output layer
Throws:
ClassificationException
Since:
0.2.0, Serguei

train

public final void train(double[] in,
                        int expected,
                        double trainconst)
                 throws ClassificationException
Actual training of the net

Parameters:
in - double[]
expected - int
trainconst - double
Throws:
ClassificationException

commit

public final void commit()
Applies changes made to neurons on every net's layer


dump

public void dump()
          throws java.io.IOException
Dumps Neural Net to an XML file

Specified by:
dump in interface StorageManager
Overrides:
dump in class Classification
Throws:
java.io.IOException

restore

public void restore()
             throws java.io.IOException
Restores Neural Net from an XML file

Specified by:
restore in interface StorageManager
Overrides:
restore in class Classification
Throws:
java.io.IOException