[marf-cvs] marf/src/marf/Classification/NeuralNetwork NeuralNetwork.java, 1.56, 1.57
Brought to you by:
mokhov
From: Serguei A. M. <mo...@us...> - 2006-07-31 02:19:22
|
Update of /cvsroot/marf/marf/src/marf/Classification/NeuralNetwork In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv23576/marf/Classification/NeuralNetwork Modified Files: NeuralNetwork.java Log Message: Add new Classification API of train(double[]) and classify(double[]) that accept feature vectors directly withough going through the entire pipeline. These make it the Classification modules more flexible and easier to test in the distributed environment. The train() method was made generic and relies on FeatureExtraction to provide such a vector as before; thus, making train() more pipeline-oriented. Clean up some dead code away. Update some minor comments. Index: NeuralNetwork.java =================================================================== RCS file: /cvsroot/marf/marf/src/marf/Classification/NeuralNetwork/NeuralNetwork.java,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** NeuralNetwork.java 28 Jul 2006 17:13:02 -0000 1.56 --- NeuralNetwork.java 31 Jul 2006 02:19:13 -0000 1.57 *************** *** 174,179 **** //this.oObjectToSerialize = this; // this.iCurrentDumpMode = DUMP_XML; ! // this.iCurrentDumpMode = DUMP_GZIP_BINARY; ! this.iCurrentDumpMode = DUMP_BINARY; this.strFilename = getDefaultFilename(); } --- 174,179 ---- //this.oObjectToSerialize = this; // this.iCurrentDumpMode = DUMP_XML; ! this.iCurrentDumpMode = DUMP_GZIP_BINARY; ! // this.iCurrentDumpMode = DUMP_BINARY; this.strFilename = getDefaultFilename(); } *************** *** 182,187 **** /** ! * Implementes training of Neural Net. ! * @return <code>true</code> * @throws ClassificationException if there are any errors * @throws NullPointerException if module parameters are incorrectly set --- 182,187 ---- /** ! * Implements training of Neural Net. ! * @return <code>true</code> if training was successful * @throws ClassificationException if there are any errors * @throws NullPointerException if module parameters are incorrectly set *************** *** 190,193 **** --- 190,221 ---- throws ClassificationException { + return trainImplementation(null); + } + + /** + * Implements training of Neural Net given the feature vector. + * @param padFeatureVector the feature vector to train on + * @return <code>true</code> if training was successful + * @throws ClassificationException if there are any errors + * @throws NullPointerException if module parameters are incorrectly set + * @since 0.3.0.6 + */ + public final boolean train(double[] padFeatureVector) + throws ClassificationException + { + return trainImplementation(padFeatureVector); + } + + /** + * Implements training of Neural Net. + * @param padFeatureVector the feature vector to train on; if null pipelining mode is used + * @return <code>true</code> if training was successful + * @throws ClassificationException if there are any errors + * @throws NullPointerException if module parameters are incorrectly set + * @since 0.3.0.6 + */ + private final boolean trainImplementation(double[] padFeatureVector) + throws ClassificationException + { Vector oTrainingSamples = null; Vector oParams = null; *************** *** 200,207 **** */ int iBackupDumpMode = this.iCurrentDumpMode; ! this.iCurrentDumpMode = DUMP_BINARY; ! // this.iCurrentDumpMode = DUMP_GZIP_BINARY; ! ! super.train(); this.iCurrentDumpMode = iBackupDumpMode; --- 228,242 ---- */ int iBackupDumpMode = this.iCurrentDumpMode; ! // this.iCurrentDumpMode = DUMP_BINARY; ! this.iCurrentDumpMode = DUMP_GZIP_BINARY; ! ! if(padFeatureVector == null) ! { ! super.train(); ! } ! else ! { ! super.train(padFeatureVector); ! } this.iCurrentDumpMode = iBackupDumpMode; *************** *** 306,311 **** --- 341,350 ---- } + /** * Neural Network implementation of classification routine. + * In 0.3.0.6 the generic pipelined verision of this API + * <code>classify()</code> was refactored into the + * <code>Classification</code>. * * @return <code>true</code> upon successful classification *************** *** 315,324 **** * if there was a StorageException during dump/restore. */ ! public final boolean classify() throws ClassificationException { try { ! double[] adFeatures = this.oFeatureExtraction.getFeaturesArray(); // Reload trained net --- 354,364 ---- * if there was a StorageException during dump/restore. */ ! public final boolean classify(double[] padFeatureVector) throws ClassificationException { try { ! // double[] adFeatures = this.oFeatureExtraction.getFeaturesArray(); ! double[] adFeatures = padFeatureVector; // Reload trained net |