[marf-cvs] marf/src/marf/Classification/NeuralNetwork NeuralNetwork.java, 1.58, 1.59
Brought to you by:
mokhov
From: Serguei A. M. <mo...@us...> - 2007-08-05 22:02:09
|
Update of /cvsroot/marf/marf/src/marf/Classification/NeuralNetwork In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18589/src/marf/Classification/NeuralNetwork Modified Files: NeuralNetwork.java Log Message: Introduce the ITrainingSample interface to represent the common training sample beans. Have the training sample hierarchy to implement this initial version of the interface and integrate it into the Classification framework. Provide first implementation of the FeatureSet bean that actually works and allows not only mean vector-based classification, but also median, which maxizes the amount of better classifications. The refactors out a complete dependency on the Cluster class among the Classification modules, and allow any of the TrainingSample, Cluster, or TrainingSet beans to be used. As a refactor the beans' implementation to allow the TrainingSet to be the extension of the Cluster and reduce amount of the duplicated code. In the implementation of the FeatureSet employ dynamic programming to cache intermediate results of computed mean and median vetors and recompute them only if the set is modified to allow efficient run-time performance by computing mean or median only once. Enhance error reporting in places and clean up some comments. Index: NeuralNetwork.java =================================================================== RCS file: /cvsroot/marf/marf/src/marf/Classification/NeuralNetwork/NeuralNetwork.java,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** NeuralNetwork.java 31 Jul 2006 14:33:47 -0000 1.58 --- NeuralNetwork.java 5 Aug 2007 22:01:32 -0000 1.59 *************** *** 19,23 **** import marf.Classification.ClassificationException; import marf.FeatureExtraction.IFeatureExtraction; ! import marf.Storage.Cluster; import marf.Storage.Result; import marf.Storage.StorageException; --- 19,23 ---- import marf.Classification.ClassificationException; import marf.FeatureExtraction.IFeatureExtraction; ! import marf.Storage.ITrainingSample; import marf.Storage.Result; import marf.Storage.StorageException; *************** *** 277,282 **** for(int i = 0; i < oTrainingSamples.size(); i++) { ! Cluster oCluster = (Cluster)oTrainingSamples.get(i); ! train(oCluster.getMeanVector(), oCluster.getSubjectID(), dTrainConst); // Commit modified weight --- 277,283 ---- for(int i = 0; i < oTrainingSamples.size(); i++) { ! // Cluster oCluster = (Cluster)oTrainingSamples.get(i); ! ITrainingSample oTrainingSample = (ITrainingSample)oTrainingSamples.get(i); ! train(oTrainingSample.getMeanVector(), oTrainingSample.getSubjectID(), dTrainConst); // Commit modified weight *************** *** 291,297 **** for(iCount = 0; iCount < oTrainingSamples.size(); iCount++) { ! Cluster oCluster = (Cluster)oTrainingSamples.get(iCount); ! setInputs(oCluster.getMeanVector()); runNNet(); --- 292,300 ---- for(iCount = 0; iCount < oTrainingSamples.size(); iCount++) { ! // Cluster oCluster = (Cluster)oTrainingSamples.get(iCount); ! ITrainingSample oTrainingSample = (ITrainingSample)oTrainingSamples.get(iCount); ! // XXX: can be median and feature vectors ! setInputs(oTrainingSample.getMeanVector()); runNNet(); *************** *** 299,305 **** // dError += Math.abs(oCluster.getSubjectID() - iID); ! dError += dMinErr * Math.abs(oCluster.getSubjectID() - iID); ! Debug.debug("Expected: " + oCluster.getSubjectID() + ", Got: " + iID + ", Error: " + dError); } --- 302,308 ---- // dError += Math.abs(oCluster.getSubjectID() - iID); ! dError += dMinErr * Math.abs(oTrainingSample.getSubjectID() - iID); ! Debug.debug("Expected: " + oTrainingSample.getSubjectID() + ", Got: " + iID + ", Error: " + dError); } |