// file: $isip/class/pr/NeuralNetwork/NeuralNetwork.h // // make sure definitions are only made once // #ifndef ISIP_NEURAL_NETWORK #define ISIP_NEURAL_NETWORK #ifndef ISIP_STRING #include #endif #ifndef ISIP_VECTOR #include #endif #ifndef ISIP_VECTOR_FLOAT #include #endif #ifndef ISIP_MATRIX_FLOAT #include #endif #ifndef ISIP_MEMORY_MANAGER #include #endif // NeuralNetwork: a class that implements a massively distributed processor // made up of simple processing units, which has a natural propensity for // storing experiential knowladge and making it available for use. // // References: // // [1] Elaine, Rich and Knight, "Artificial Intelligence", Second Edition, // McGraw Hill, New York, 1991. // // [2] S. Haykin, "Neural Networks", Second Edition, Prentice Hall, // New Jersey, 1999. // class NeuralNetwork { //--------------------------------------------------------------------------- // // public constants // //--------------------------------------------------------------------------- public: // define the class name // static const String CLASS_NAME; //---------------------------------------- // // i/o related constants // //---------------------------------------- static const String DEF_PARAM; static const String DEF_COMMENT_TAG; //---------------------------------------- // // default values and arguments // //---------------------------------------- static const float32 DEF_ETA = 0.35; static const float32 DEF_BIAS = 1.0; static const float32 DEF_MOMENTUM = 0.1; static const int32 DEF_EPOCHS = 1; static const int32 DEF_HIDDEN_UNITS = 1; static const int32 DEF_HIDDEN_LAYERS = 1; //--------------------------------------------------------------------------- // // public data // //-------------------------------------------------------------------------- // define the input features // Vector features_d; // define the reference target // Vector outputs_d; // define the test features // Vector test_features_d; // define the test reference target // Vector test_outputs_d; //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // a static debug level // static Integral::DEBUG debug_level_d; // a static memory manager // static MemoryManager mgr_d; //--------------------------------------------------------------------------- // // required public methods // //--------------------------------------------------------------------------- public: // method: name // static const String& name() { return CLASS_NAME; } // other static methods // static bool8 diagnose(Integral::DEBUG debug_level); // method: setDebug // static bool8 setDebug(Integral::DEBUG level) { debug_level_d = level; return true; } // method: debug // bool8 debug(const unichar* msg) const { return true; } // method: destructor // ~NeuralNetwork() {} // method: default constructor // NeuralNetwork(); // method: copy constructor // NeuralNetwork(const NeuralNetwork& arg) { assign(arg); } // method: assign // bool8 assign(const NeuralNetwork& copy_node) { return true; } // method: operator= // NeuralNetwork& operator= (const NeuralNetwork& arg) { assign(arg); return *this; } // method: new // static void* operator new(size_t size) { return mgr_d.get(); } // method: new[] // static void* operator new[](size_t size) { return mgr_d.getBlock(size); } // method: delete // static void operator delete(void* ptr) { mgr_d.release(ptr); } // method: delete[] // static void operator delete[](void* ptr) { mgr_d.releaseBlock(ptr); } // method: setGrowSize // static bool8 setGrowSize(int32 grow_size) { return mgr_d.setGrow(grow_size); } // method: clear // bool8 clear(Integral::CMODE cmode = Integral::DEF_CMODE) { return true; } //--------------------------------------------------------------------------- // // class-specific public methods // //--------------------------------------------------------------------------- // method: setEpochs // bool8 setEpochs(int32 arg) { epochs_d = arg; return true; } // method: getEpochs // int32 getEpochs() { return epochs_d; } // method: setLearningRate // bool8 setLearningRate(float32 arg) { eta_d = arg; return true; } // method: getLearningRate // float32 getLearningRate() { return eta_d; } // method: setMomentum // bool8 setMomentum(float32 arg) { momentum_d = arg; return true; } // method: getMomentum // float32 getMomentum() { return momentum_d; } // method: setBias // bool8 setBias(float32 arg) { bias_d = arg; return true; } // method: getBias // float32 getBias() { return bias_d; } // this method initialize the neural network // bool8 init(int32 epochs, int32 units, int32 layers = DEF_HIDDEN_LAYERS, float32 bias = DEF_BIAS, float32 rate = DEF_ETA, float32 momentum = DEF_MOMENTUM); // this method load the feature vectors used to train the neural network // bool8 loadFeatures(String& arg); // this method load the training target values // bool8 loadOutputs(String& arg); // this method load the feature vectors used to test the neural network // bool8 loadTestFeatures(String& arg); // this method load the testing target values // bool8 loadTestOutputs(String& arg); // this method loads the training data and determines the weights // for the neural network // bool8 train(String& train, String& output, String& model); // this method loads the models and testing data and generates results // bool8 test(String& model, String& test, String& output); // write the model to file // bool8 writeModel(String& arg); //--------------------------------------------------------------------------- // // private data // //--------------------------------------------------------------------------- private: // define the bias parameter // float32 bias_d; // define the learning rate and momentum // float32 eta_d; float32 momentum_d; // define the number of epochs // int32 epochs_d; // define the weights from the input to the hidden layer // MatrixFloat w1_d; // define the weights from the hidden to the output layer // MatrixFloat w2_d; // define the weights within the hidden layers // Vector h1_d; // define the hidden layer/layers // Vector hidden_layers_d; // define the input layer // VectorFloat input_layer_d; // define the output layer // VectorFloat output_layer_d; //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: // method the randomize the }; // end of include file // #endif