PLearn 0.1
|
00001 // -*- C++ -*- 00002 00003 // PLearn (A C++ Machine Learning Library) 00004 // Copyright (C) 1998 Pascal Vincent 00005 // Copyright (C) 1999-2001 Pascal Vincent, Yoshua Bengio, Rejean Ducharme and University of Montreal 00006 // Copyright (C) 2002 Pascal Vincent, Julien Keable, Xavier Saint-Mleux 00007 // 00008 // Redistribution and use in source and binary forms, with or without 00009 // modification, are permitted provided that the following conditions are met: 00010 // 00011 // 1. Redistributions of source code must retain the above copyright 00012 // notice, this list of conditions and the following disclaimer. 00013 // 00014 // 2. Redistributions in binary form must reproduce the above copyright 00015 // notice, this list of conditions and the following disclaimer in the 00016 // documentation and/or other materials provided with the distribution. 00017 // 00018 // 3. The name of the authors may not be used to endorse or promote 00019 // products derived from this software without specific prior written 00020 // permission. 00021 // 00022 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 00023 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00024 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 00025 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00026 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 00027 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00028 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00029 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00030 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00031 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00032 // 00033 // This file is part of the PLearn library. For more information on the PLearn 00034 // library, go to the PLearn Web site at www.plearn.org 00035 00036 00037 /* ******************************************************* 00038 * $Id: ShiftAndRescaleVMatrix.h 10178 2009-05-06 15:21:16Z nouiz $ 00039 ******************************************************* */ 00040 00041 00044 #ifndef ShiftAndRescaleVMatrix_INC 00045 #define ShiftAndRescaleVMatrix_INC 00046 00047 #include "VMat.h" 00048 #include "SourceVMatrix.h" 00049 00050 namespace PLearn { 00051 using namespace std; 00052 00058 class ShiftAndRescaleVMatrix: public SourceVMatrix 00059 { 00060 typedef SourceVMatrix inherited; 00061 00062 public: 00064 00065 // DEPRECATED - use inherited::source instead 00066 // VMat vm; 00067 Vec shift; 00068 Vec scale; 00069 Vec min_max; 00070 00071 real shared_shift; 00072 real shared_scale; 00073 00075 bool automatic; 00076 00079 int n_train; 00080 int n_inputs; // when automatic, 00081 bool negate_shift; 00082 bool no_scale; 00083 TVec<string> fields; 00084 int verbosity; 00085 00087 ShiftAndRescaleVMatrix(bool call_build_=false); 00088 00089 ShiftAndRescaleVMatrix(VMat the_source, bool call_build_=true); 00090 00091 ShiftAndRescaleVMatrix(VMat the_source, Vec the_shift, Vec the_scale, 00092 bool call_build_=true); 00093 00094 ShiftAndRescaleVMatrix(VMat the_source, int the_n_inputs, 00095 bool call_build_=true); 00096 00097 ShiftAndRescaleVMatrix(VMat the_source, 00098 int the_n_inputs, 00099 int the_n_train, 00100 bool the_ignore_missing = false, 00101 bool the_verbosity = 1, 00102 bool call_build_=true); 00103 00104 PLEARN_DECLARE_OBJECT(ShiftAndRescaleVMatrix); 00105 00107 virtual void makeDeepCopyFromShallowCopy(CopiesMap& copies); 00108 00109 virtual void getNewRow(int i, const Vec& v) const; 00110 00111 virtual void reset_dimensions() 00112 { 00113 if (width_>0 && width_!=source->width()) 00114 PLERROR("ShiftAndRescaleVMatrix: can't change width"); 00115 inherited::reset_dimensions(); 00116 } 00117 00118 private: 00120 void build_(); 00121 00122 protected: 00124 static void declareOptions(OptionList& ol); 00125 00126 public: 00127 // simply calls inherited::build() then build_() 00128 virtual void build(); 00129 00130 }; 00131 00132 // Declares a few other classes and functions related to this class 00133 DECLARE_OBJECT_PTR(ShiftAndRescaleVMatrix); 00134 00135 } // end of namespace PLearn 00136 #endif 00137 00138 00139 /* 00140 Local Variables: 00141 mode:c++ 00142 c-basic-offset:4 00143 c-file-style:"stroustrup" 00144 c-file-offsets:((innamespace . 0)(inline-open . 0)) 00145 indent-tabs-mode:nil 00146 fill-column:79 00147 End: 00148 */ 00149 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=79 :