Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

EmbeddedLearner.cc

Go to the documentation of this file.
00001 // -*- C++ -*- 00002 00003 // EmbeddedLearner.cc 00004 // 00005 // Copyright (C) 2002 Frederic Morin 00006 // Copyright (C) 2003 Pascal Vincent 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 * $Id: EmbeddedLearner.cc,v 1.12 2004/06/26 00:24:15 plearner Exp $ 00038 ******************************************************* */ 00039 00041 #include "EmbeddedLearner.h" 00042 00043 namespace PLearn { 00044 using namespace std; 00045 00046 // ###### EmbeddedLearner ###################################################### 00047 00048 PLEARN_IMPLEMENT_OBJECT(EmbeddedLearner, "Wraps an underlying learner", 00049 "EmbeddedLearner implements nothing but forwarding \n" 00050 "calls to an underlying learner. It is typically used as\n" 00051 "baseclass for learners that are built on top of another learner"); 00052 00053 EmbeddedLearner::EmbeddedLearner() 00054 {} 00055 00056 void EmbeddedLearner::declareOptions(OptionList& ol) 00057 { 00058 declareOption(ol, "learner", &EmbeddedLearner::learner_, OptionBase::buildoption, 00059 "The embedded learner"); 00060 inherited::declareOptions(ol); 00061 } 00062 00063 void EmbeddedLearner::build_() 00064 { 00065 if (!learner_) 00066 PLERROR("EmbeddedLearner::_build() - learner_ attribute is NULL"); 00067 00068 learner_->build(); 00069 } 00070 00071 void EmbeddedLearner::build() 00072 { 00073 inherited::build(); 00074 build_(); 00075 } 00076 00077 00078 void EmbeddedLearner::forget() 00079 { learner_->forget(); } 00080 00081 int EmbeddedLearner::inputsize() const 00082 { return learner_->inputsize(); } 00083 00084 int EmbeddedLearner::targetsize() const 00085 { return learner_->targetsize(); } 00086 00087 int EmbeddedLearner::outputsize() const 00088 { return learner_->outputsize(); } 00089 00090 void EmbeddedLearner::train() 00091 { learner_->train(); } 00092 00093 void EmbeddedLearner::test(VMat testset, PP<VecStatsCollector> test_stats, 00094 VMat testoutputs, VMat testcosts) const 00095 { 00096 learner_->test(testset, test_stats, testoutputs, testcosts); 00097 } 00098 00099 void EmbeddedLearner::computeOutput(const Vec& input, Vec& output) const 00100 { 00101 learner_->computeOutput(input, output); 00102 } 00103 00104 void EmbeddedLearner::computeCostsFromOutputs(const Vec& input, const Vec& output, 00105 const Vec& target, Vec& costs) const 00106 { 00107 learner_->computeCostsFromOutputs(input, output, target, costs); 00108 } 00109 00110 void EmbeddedLearner::computeOutputAndCosts(const Vec& input, const Vec& target, 00111 Vec& output, Vec& costs) const 00112 { 00113 learner_->computeOutputAndCosts(input, target, output, costs); 00114 } 00115 00116 void EmbeddedLearner::computeCostsOnly(const Vec& input, const Vec& target, Vec& costs) const 00117 { learner_->computeCostsOnly(input, target, costs); } 00118 00119 TVec<string> EmbeddedLearner::getTestCostNames() const 00120 { return learner_->getTestCostNames(); } 00121 00122 TVec<string> EmbeddedLearner::getTrainCostNames() const 00123 { return learner_->getTrainCostNames(); } 00124 00125 void EmbeddedLearner::makeDeepCopyFromShallowCopy(map<const void*, void*>& copies) 00126 { 00127 PLearner::makeDeepCopyFromShallowCopy(copies); 00128 00129 // ### Call deepCopyField on all "pointer-like" fields 00130 // ### that you wish to be deepCopied rather than 00131 // ### shallow-copied. 00132 deepCopyField(learner_, copies); 00133 } 00134 00135 } // end of namespace PLearn

Generated on Tue Aug 17 15:52:01 2004 for PLearn by doxygen 1.3.7