00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00041
#include "EmbeddedLearner.h"
00042
00043
namespace PLearn {
00044
using namespace std;
00045
00046
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
00130
00131
00132
deepCopyField(
learner_, copies);
00133 }
00134
00135 }