Main Page   Class Hierarchy   Compound List   File List   Compound Members  

VowelClassifier.h

00001 /* VowelClassifier.h
00002  *
00003  * Copyright (C) 2002-2003 -- Sebastian Nowozin
00004  */
00005 
00006 #ifndef VOWELCLASSIFIER_H
00007 #define VOWELCLASSIFIER_H
00008 
00009 #include <vowel/VowelSample.h>
00010 #include <neuralnet/PerceptronNetwork.h>
00011 #include <neuralnet/RandomFunction.h>
00012 
00013 #include <vector>
00014 #include <map>
00015 #include <fstream>
00016 
00017 
00020 typedef struct {
00030         vector<double>          vstat;
00031 
00037         vector<vector<double> > net_result;
00038 
00045         VowelSampleType         guessed_type;
00046 } VowelClassification;
00047 
00048 
00056 typedef struct {
00058         vector<unsigned int>    net1;
00060         vector<unsigned int>    net2;
00062         vector<unsigned int>    net3;
00063 } VowelClassifierLayout;
00064 
00065 
00072 typedef struct {
00075         double  epsilon;
00076 
00079         double  optimal_tolerance;
00080 
00083         double  weight_decay;
00084 
00087         double  momentum_term;
00088 } VowelClassifierLearnParams;
00089 
00090 
00091 
00096 class
00097 VowelClassifier {
00098 public:
00118         static vector<double> correct_results[3][(VowelSampleType) Unknown + 1];
00119 
00130         VowelClassifier (unsigned int input_dim,
00131                 const VowelClassifierLayout *layout);
00132 
00133 
00134         /* Default constructor. (To be used with the load method).
00135          */
00136         VowelClassifier (void);
00137 
00140         ~VowelClassifier (void);
00141 
00146         VowelClassifier (VowelClassifier& source);
00147 
00148         /* LOAD/SAVE methods */
00149 
00156         bool load (fstream& fs);
00157 
00162         void save (fstream& fs) const;
00163 
00168         VowelClassification classifyVowel (const VowelSample *input);
00169 
00183         void learnVowel (const VowelSample *input);
00184 
00191         void updateLearned (void);
00192 
00199         void resetLearned (void);
00200 
00208         void setLearningParameters (VowelClassifierLearnParams params);
00209 
00212         VowelClassifierLearnParams getLearningParameters (void) const;
00213 
00222         const char *getExpertName (unsigned int expert_number);
00223 
00229         void randomizeExpert (unsigned int expert);
00230 
00239         void setRandomizationParameters (unsigned int expert,
00240                 double weight_low, double weight_high,
00241                 double theta_low, double theta_high);
00242 
00253         bool setActivationFunction (unsigned int expert_number,
00254                 PerceptronLayerType type, const char *fact_name);
00255 
00262         PerceptronNetwork * getNetwork (unsigned int expert_number) const;
00263 
00264 private:
00265 
00274         vector<double> getExpertResults (PerceptronNetwork *exp,
00275                 vector<double> in);
00276 
00284         void singleExpertLearn (PerceptronNetwork *exp, vector<double> input,
00285                 vector<double> optimal);
00286 
00290         PerceptronNetwork *     nn_a_ou_ei;
00291 
00295         PerceptronNetwork *     nn_o_u_aei;
00296 
00300         PerceptronNetwork *     nn_e_i_aou;
00301 
00304         VowelClassifierLearnParams      lpar;
00305 
00308         vector<RandomInterval>  weight_initializations;
00309 
00312         vector<RandomInterval>  theta_initializations;
00313 
00314         /* STATIC elements */
00315 
00318         struct VScompare {
00322                 bool operator () (const VowelSampleType s1,
00323                         const VowelSampleType s2) const
00324                 {
00325                         return (s1 < s2);
00326                 }
00327         };
00328 
00331         void initializeCorrectResults (void);
00332 };
00333 
00334 
00335 
00336 #endif
00337 
00338 

Generated on Mon Feb 24 19:37:43 2003 by doxygen1.3-rc3