PLearn 0.1
|
00001 // -*- C++ -*- 00002 00003 // PLearnerOutputVMatrix.h 00004 // 00005 // Copyright (C) 2003 Yoshua Bengio 00006 // 00007 // Redistribution and use in source and binary forms, with or without 00008 // modification, are permitted provided that the following conditions are met: 00009 // 00010 // 1. Redistributions of source code must retain the above copyright 00011 // notice, this list of conditions and the following disclaimer. 00012 // 00013 // 2. Redistributions in binary form must reproduce the above copyright 00014 // notice, this list of conditions and the following disclaimer in the 00015 // documentation and/or other materials provided with the distribution. 00016 // 00017 // 3. The name of the authors may not be used to endorse or promote 00018 // products derived from this software without specific prior written 00019 // permission. 00020 // 00021 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 00022 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00023 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 00024 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00025 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 00026 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00027 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00028 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00029 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00030 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00031 // 00032 // This file is part of the PLearn library. For more information on the PLearn 00033 // library, go to the PLearn Web site at www.plearn.org 00034 00035 /* ******************************************************* 00036 * $Id: PLearnerOutputVMatrix.h 5842 2006-06-13 19:22:56Z plearner $ 00037 ******************************************************* */ 00038 00039 // Authors: Yoshua Bengio 00040 00044 #ifndef PLearnerOutputVMatrix_INC 00045 #define PLearnerOutputVMatrix_INC 00046 00047 #include "SourceVMatrix.h" 00048 #include "VMat.h" 00049 #include <plearn_learners/generic/PLearner.h> 00050 00051 namespace PLearn { 00052 using namespace std; 00053 00054 class PLearnerOutputVMatrix: public SourceVMatrix 00055 { 00056 typedef SourceVMatrix inherited; 00057 00058 protected: 00059 // ********************* 00060 // * protected options * 00061 // ********************* 00062 00063 // NON-OPTIONs 00064 00065 mutable Vec row; 00066 mutable Vec learner_input; 00068 mutable TVec< Vec > learners_output; 00069 mutable Vec learner_target; 00070 mutable Vec non_input_part_of_source_row; 00072 mutable bool learners_need_train; 00073 mutable TVec<Mat> complete_learners_output; 00074 00075 public: 00076 00077 // ************************ 00078 // * public build options * 00079 // ************************ 00080 00081 VMat fieldinfos_source; 00082 00083 // DEPRECATED - we now use 'source' instead. 00084 //VMat data; // whose input field will be applied to learner in order to obtain new input part of this VMatrix 00085 VMat data_train; 00086 00087 // the outputs of the learners will be concatenated 00088 TVec< PP<PLearner> > learners; 00089 00090 // if true not only the learner output but also the raw source input 00091 // are in the input part of the VMatrix 00092 bool put_raw_input; 00093 bool put_non_input; 00094 bool train_learners; 00095 bool compute_output_once; 00096 00097 // **************** 00098 // * Constructors * 00099 // **************** 00100 00101 // Default constructor, make sure the implementation in the .cc 00102 // initializes all fields to reasonable default values. 00103 PLearnerOutputVMatrix(bool call_build_ = false); 00104 PLearnerOutputVMatrix(VMat source_, 00105 TVec< PP<PLearner> > learners_, 00106 bool put_raw_input_=false, 00107 bool train_learners_ = false, 00108 bool compute_output_once_ = false, 00109 bool put_non_input_ = true, 00110 bool call_build_ = true); 00111 00112 // same but for a single learner 00113 PLearnerOutputVMatrix(VMat source_, 00114 PP<PLearner> learner, 00115 bool put_raw_input_=false, 00116 bool train_learners_ = false, 00117 bool compute_output_once_ = false, 00118 bool put_non_input_ = true, 00119 bool call_build_ = true); 00120 00121 // ****************** 00122 // * Object methods * 00123 // ****************** 00124 00125 private: 00127 void build_(); 00128 00129 protected: 00131 static void declareOptions(OptionList& ol); 00132 00134 virtual void getNewRow(int i, const Vec& v) const; 00135 00136 public: 00137 // simply calls inherited::build() then build_() 00138 virtual void build(); 00139 00141 virtual void makeDeepCopyFromShallowCopy(CopiesMap& copies); 00142 00144 PLEARN_DECLARE_OBJECT(PLearnerOutputVMatrix); 00145 00146 }; 00147 00148 DECLARE_OBJECT_PTR(PLearnerOutputVMatrix); 00149 00150 } // end of namespace PLearn 00151 #endif 00152 00153 00154 /* 00155 Local Variables: 00156 mode:c++ 00157 c-basic-offset:4 00158 c-file-style:"stroustrup" 00159 c-file-offsets:((innamespace . 0)(inline-open . 0)) 00160 indent-tabs-mode:nil 00161 fill-column:79 00162 End: 00163 */ 00164 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=79 :