/****************************************************************************************/ /* */ /* Project : 1D-BRNN */ /* Release : 3.3 */ /* */ /* File : Model.h */ /* Description : BRNN model with three neural networks */ /* */ /* Author(s) : Christophe Magnan (2013) - New generic version */ /* : Jianlin Cheng (2003) - New custom version for SCRATCH */ /* : Gianluca Pollastri (2001) - Customized version for SCRATCH */ /* : Paolo Frasconi (1997) - Initial generic version */ /* */ /* Copyright : Institute for Genomics and Bioinformatics */ /* University of California, Irvine */ /* */ /* Modified : 2015/07/01 */ /* */ /****************************************************************************************/ #include "Dataset.h" #include "Network.h" class Model { public: // Model parameters int Num_Features; // Number of data features in input of the BRNN int Num_Classes; // Number of target classes in output of the BRNN int Num_Hidden; // Number of hidden nodes in the main network of the BRNN int Num_AdjPos_FWD; // Number of adjacent positions s.t. outputs of forward network -> inputs of main network int Num_AdjPos_BWD; // Number of adjacent positions s.t. outputs of backward network -> inputs of main network int Num_Outputs_FWD; // Number of output nodes in the forward network of the BRNN int Num_Outputs_BWD; // Number of output nodes in the backward network of the BRNN int Num_Hidden_FWD; // Number of hidden nodes in the forward network of the BRNN int Num_Hidden_BWD; // Number of hidden nodes in the backward network of the BRNN // Model data Network* MAINnet; // Main network of the BRNN (with output layer) Network* FWDnet; // Forward network of the BRNN (left context) Network* BWDnet; // Backward network of the BRNN (right context) // Propagation data float* Inputs_MAIN; // Next inputs to propagate in the main network of the BRNN float* Inputs_FWD; // Next inputs to propagate in the forward network of the BRNN float* Inputs_BWD; // Next inputs to propagate in the backward network of the BRNN // Interface Model(); ~Model(); void write(char* fileout); void load(char* filein); void initialize(int feat,int cl,int hid,int cF,int cB,int oF,int oB,int hF,int hB); void alloc_backpropagation(); void propagate(Sequence* seq); void expectation(Sequence* seq); void maximization(float epsilon); private: // Methods void propagate_FWD(Sequence* seq,int pos); void propagate_BWD(Sequence* seq,int pos); void propagate_MAIN(Sequence* seq,int pos); void back_propagate_FWD(Sequence* seq,int pos); void back_propagate_BWD(Sequence* seq,int pos); void back_propagate_MAIN(Sequence* seq,int pos); void check_viability(); };