|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object marf.Storage.StorageManager marf.Classification.Classification marf.Classification.NeuralNetwork.NeuralNetwork
public class NeuralNetwork
Artificial Neural Network-based Classifier.
$Id: NeuralNetwork.java,v 1.61 2008/02/05 22:13:30 mokhov Exp $
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. |
static java.lang.String |
JAXP_SCHEMA_LANGUAGE
JAXP 1.2 Schema. |
static java.lang.String |
JAXP_SCHEMA_SOURCE
JAXP 1.2 Schema URL. |
static java.lang.String |
OUTPUT_ENCODING
All output will use this encoding. |
static java.lang.String |
W3C_XML_SCHEMA
XML 2001 Schema. |
Fields inherited from class marf.Classification.Classification |
---|
adFeatureVector, oFeatureExtraction, oResultSet, oTrainingSet |
Fields inherited from class marf.Storage.StorageManager |
---|
bDumpOnNotFound, iCurrentDumpMode, oObjectToSerialize, strFilename |
Fields inherited from interface marf.Classification.IClassification |
---|
MARF_INTERFACE_CODE_REVISION |
Fields inherited from interface marf.Storage.IStorageManager |
---|
DUMP_BINARY, DUMP_CSV_TEXT, DUMP_GZIP_BINARY, DUMP_HTML, DUMP_SQL, DUMP_XML, MARF_INTERFACE_CODE_REVISION, STORAGE_FILE_EXTENSIONS |
Constructor Summary | |
---|---|
NeuralNetwork(IFeatureExtraction poFeatureExtraction)
NeuralNetwork Constructor. |
Method Summary | |
---|---|
void |
backSynchronizeObject()
Must to be overridden by the modules that use object serialization with the generic implementation of restore() . |
boolean |
classify(double[] padFeatureVector)
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 or serialized file. |
void |
dumpXML()
Overrides the default implementation of dumpXML() . |
void |
dumpXML(java.lang.String pstrFilename)
Dumps Neural Network as XML file. |
void |
eval()
Evaluates the entire neural network. |
void |
generate()
Generates the initial network at random with the default parameters. |
void |
generate(int piNumOfInputs,
int[] paiHiddenLayers,
int piNumOfOutputs)
Generates a virgin net at random. |
protected java.lang.String |
getDefaultFilename()
Generates typical filename for dump/restore. |
static java.lang.String |
getMARFSourceCodeRevision()
Retrieves class' revision. |
double[] |
getOutputResults()
Gets outputs of a neural network run. |
Result |
getResult()
Retrieves the minimum-error classification result. |
static void |
indent(java.io.BufferedWriter poWriter,
int piTabsNum)
Indents the output according to the requested tabulation for pretty indentation. |
void |
initialize(java.lang.String pstrFilename,
boolean pbValidateDTD)
Parses XML and produces a neural network data structure. |
void |
restore()
Restores Neural Net from an XML or serialized file. |
void |
restoreXML()
Overrides the default implementation of restoreXML() . |
void |
setInputs(double[] padInputs)
Sets inputs. |
boolean |
train()
Implements training of Neural Net. |
boolean |
train(double[] padFeatureVector)
Implements training of Neural Net given the feature vector. |
void |
train(double[] padInput,
int piExpectedLength,
double pdTrainConst)
Performs Actual training of the net. |
Methods inherited from class marf.Classification.Classification |
---|
classify, clone, getFeatureExtraction, getResultSet, getTrainingSetFilename, loadTrainingSet, setFeatureExtraction |
Methods inherited from class marf.Storage.StorageManager |
---|
dumpBinary, dumpCSV, dumpGzipBinary, dumpHTML, dumpSQL, enableDumpOnNotFound, equals, getDefaultExtension, getDefaultExtension, getDumpMode, getFilename, getObjectToSerialize, hashCode, restoreBinary, restoreCSV, restoreGzipBinary, restoreHTML, restoreSQL, setDumpMode, setFilename, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_OUTPUT_NEURON_BITS
public static final double DEFAULT_TRAINING_CONSTANT
1
if none supplied.
public static final int DEFAULT_EPOCH_NUMBER
64
if none supplied.
public static final double DEFAULT_MIN_ERROR
0.1
if none supplied.
public static final java.lang.String OUTPUT_ENCODING
public static final java.lang.String JAXP_SCHEMA_LANGUAGE
public static final java.lang.String W3C_XML_SCHEMA
public static final java.lang.String JAXP_SCHEMA_SOURCE
Constructor Detail |
---|
public NeuralNetwork(IFeatureExtraction poFeatureExtraction)
poFeatureExtraction
- FeatureExtraction module referenceMethod Detail |
---|
public final boolean train() throws ClassificationException
train
in interface IClassification
train
in class Classification
true
if training was successful
ClassificationException
- if there are any errors
java.lang.NullPointerException
- if module parameters are incorrectly setTrainingSet
public final boolean train(double[] padFeatureVector) throws ClassificationException
train
in interface IClassification
train
in class Classification
padFeatureVector
- the feature vector to train on
true
if training was successful
ClassificationException
- if there are any errors
java.lang.NullPointerException
- if module parameters are incorrectly setTrainingSet
public final boolean classify(double[] padFeatureVector) throws ClassificationException
classify()
was refactored into the
Classification
.
padFeatureVector
- vector of features to compare with the stored ones
true
upon successful classification
ClassificationException
- when input feature vector
length does not match the size of the input neuron layer or
if there was a StorageException during dump/restore.public final void eval()
public final void initialize(java.lang.String pstrFilename, boolean pbValidateDTD) throws StorageException
pstrFilename
- net's XML filenamepbValidateDTD
- if true DTD will be validated
StorageException
- if there was an I/O or otherwise error
during initialization of the netpublic void generate() throws ClassificationException
ClassificationException
DEFAULT_OUTPUT_NEURON_BITS
public final void setInputs(double[] padInputs) throws ClassificationException
padInputs
- double array of input features
ClassificationException
- if the input array's length isn't
equal to the size of the input layerpublic double[] getOutputResults()
public static final void indent(java.io.BufferedWriter poWriter, int piTabsNum) throws java.io.IOException
poWriter
- Writer object to write tabs to.piTabsNum
- number of tabs
java.io.IOException
- if there is an error writing out the tabspublic final void dumpXML(java.lang.String pstrFilename) throws StorageException
pstrFilename
- XML file name to write to
StorageException
- in case of an I/O errorpublic final void generate(int piNumOfInputs, int[] paiHiddenLayers, int piNumOfOutputs) throws ClassificationException
piNumOfInputs
- number of input Neurons in the input layerpaiHiddenLayers
- arrays of numbers of Neurons in the hidden layerspiNumOfOutputs
- number of output Neurons in the output layer
ClassificationException
- if the hidden layers array has nothing or is nullpublic final void train(double[] padInput, int piExpectedLength, double pdTrainConst) throws ClassificationException
padInput
- the input feature vectorpiExpectedLength
- expected length of the output layerpdTrainConst
- training constant to use for neurons
ClassificationException
- if the training constant less than zero or sizes
of the inputs do not match or there is a problem evaluating the networkpublic final void commit()
public void dump() throws StorageException
dump
in interface IStorageManager
dump
in class Classification
StorageException
IStorageManager.DUMP_GZIP_BINARY
,
IStorageManager.DUMP_BINARY
,
StorageManager.dumpGzipBinary()
,
StorageManager.dumpCSV()
,
StorageManager.dumpBinary()
,
StorageManager.dumpXML()
,
StorageManager.dumpHTML()
,
StorageManager.dumpSQL()
,
StorageManager.backSynchronizeObject()
,
StorageManager.iCurrentDumpMode
public void restore() throws StorageException
restore
in interface IStorageManager
restore
in class Classification
StorageException
IStorageManager.DUMP_GZIP_BINARY
,
IStorageManager.DUMP_BINARY
,
StorageManager.dumpGzipBinary()
,
StorageManager.dumpCSV()
,
StorageManager.dumpBinary()
,
StorageManager.dumpXML()
,
StorageManager.dumpHTML()
,
StorageManager.dumpSQL()
,
StorageManager.backSynchronizeObject()
,
StorageManager.iCurrentDumpMode
public void dumpXML() throws StorageException
dumpXML()
.
Merely calls dumpXML(String)
.
dumpXML
in interface IStorageManager
dumpXML
in class StorageManager
StorageException
- in case of I/O or otherwise errorIStorageManager.dumpXML()
,
dumpXML(String)
public void restoreXML() throws StorageException
restoreXML()
.
Merely calls initialize()
.
restoreXML
in interface IStorageManager
restoreXML
in class StorageManager
StorageException
- in case of I/O or otherwise errorIStorageManager.restoreXML()
,
initialize(String, boolean)
public void backSynchronizeObject()
StorageManager
restore()
. By default
this method is unimplemented.
backSynchronizeObject
in class StorageManager
StorageManager.backSynchronizeObject()
protected java.lang.String getDefaultFilename()
public Result getResult()
public static java.lang.String getMARFSourceCodeRevision()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |