PLearn 0.1
|
#include <LogaddOnBagsModule.h>
Public Member Functions | |
LogaddOnBagsModule () | |
Default constructor. | |
virtual void | fpropAcc (const Vec &input) |
update internal statistics needed to compute the output of bag | |
virtual void | fpropInit (const Vec &input) |
virtual void | fpropOutput (Vec &output) |
virtual void | bprop (const Mat &baginputs, const Vec &bagoutput_gradient, Mat &baginputs_gradients) |
compute the gradient w.r.t bag inputs | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual LogaddOnBagsModule * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Post-constructor. | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Transforms a shallow copy into a deep copy. | |
Static Public Member Functions | |
static string | _classname_ () |
static OptionList & | _getOptionList_ () |
static RemoteMethodMap & | _getRemoteMethodMap_ () |
static Object * | _new_instance_for_typemap_ () |
static bool | _isa_ (const Object *o) |
static void | _static_initialize_ () |
static const PPath & | declaringFile () |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares the class options. | |
Protected Attributes | |
Vec | accumulated_output |
Private Types | |
typedef OnBagsModule | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
Definition at line 48 of file LogaddOnBagsModule.h.
typedef OnBagsModule PLearn::LogaddOnBagsModule::inherited [private] |
Reimplemented from PLearn::OnBagsModule.
Definition at line 50 of file LogaddOnBagsModule.h.
PLearn::LogaddOnBagsModule::LogaddOnBagsModule | ( | ) |
string PLearn::LogaddOnBagsModule::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::OnBagsModule.
Definition at line 52 of file LogaddOnBagsModule.cc.
OptionList & PLearn::LogaddOnBagsModule::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::OnBagsModule.
Definition at line 52 of file LogaddOnBagsModule.cc.
RemoteMethodMap & PLearn::LogaddOnBagsModule::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::OnBagsModule.
Definition at line 52 of file LogaddOnBagsModule.cc.
Reimplemented from PLearn::OnBagsModule.
Definition at line 52 of file LogaddOnBagsModule.cc.
Object * PLearn::LogaddOnBagsModule::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::OnBagsModule.
Definition at line 52 of file LogaddOnBagsModule.cc.
StaticInitializer LogaddOnBagsModule::_static_initializer_ & PLearn::LogaddOnBagsModule::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::OnBagsModule.
Definition at line 52 of file LogaddOnBagsModule.cc.
void PLearn::LogaddOnBagsModule::bprop | ( | const Mat & | baginputs, |
const Vec & | bagoutput_gradient, | ||
Mat & | baginputs_gradients | ||
) | [virtual] |
compute the gradient w.r.t bag inputs
Reimplemented from PLearn::OnBagsModule.
Definition at line 112 of file LogaddOnBagsModule.cc.
References PLearn::TMat< T >::column(), i, PLearn::TMat< T >::length(), PLearn::TVec< T >::resize(), PLearn::TMat< T >::resize(), PLearn::softmax(), and PLearn::TMat< T >::toVecCopy().
{ int nsamples = baginputs.length(); baginputs_gradients.resize( nsamples, input_size); for( int i = 0; i < input_size; i++ ) { Vec tmp_input_gradient; tmp_input_gradient.resize( nsamples ); softmax( baginputs.column(i).toVecCopy() , tmp_input_gradient ); tmp_input_gradient *= bagoutput_gradient[i]; baginputs_gradients.column(i) << tmp_input_gradient; } }
void PLearn::LogaddOnBagsModule::build | ( | ) | [virtual] |
Post-constructor.
The normal implementation should call simply inherited::build(), then this class's build_(). This method should be callable again at later times, after modifying some option fields to change the "architecture" of the object.
Reimplemented from PLearn::OnBagsModule.
Definition at line 76 of file LogaddOnBagsModule.cc.
{ inherited::build(); build_(); }
void PLearn::LogaddOnBagsModule::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::OnBagsModule.
Definition at line 68 of file LogaddOnBagsModule.cc.
References PLASSERT.
{ PLASSERT( input_size > 0 ); output_size = input_size; accumulated_output.resize(output_size); inherited::build(); }
string PLearn::LogaddOnBagsModule::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::OnBagsModule.
Definition at line 52 of file LogaddOnBagsModule.cc.
void PLearn::LogaddOnBagsModule::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::OnBagsModule.
Definition at line 59 of file LogaddOnBagsModule.cc.
References PLearn::OptionBase::learntoption, PLearn::OnlineLearningModule::output_size, and PLearn::redeclareOption().
{ inherited::declareOptions(ol); redeclareOption(ol, "output_size", &LogaddOnBagsModule::output_size, OptionBase::learntoption, "Size of the 'output' port (same as 'input')."); }
static const PPath& PLearn::LogaddOnBagsModule::declaringFile | ( | ) | [inline, static] |
LogaddOnBagsModule * PLearn::LogaddOnBagsModule::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::OnBagsModule.
Definition at line 52 of file LogaddOnBagsModule.cc.
void PLearn::LogaddOnBagsModule::fpropAcc | ( | const Vec & | input | ) | [virtual] |
update internal statistics needed to compute the output of bag
Reimplemented from PLearn::OnBagsModule.
Definition at line 96 of file LogaddOnBagsModule.cc.
References i, and PLearn::logadd().
{ for( int i = 0; i < input_size; i++ ) accumulated_output[i] = logadd(accumulated_output[i], input[i]); }
void PLearn::LogaddOnBagsModule::fpropInit | ( | const Vec & | input | ) | [virtual] |
Reimplemented from PLearn::OnBagsModule.
Definition at line 92 of file LogaddOnBagsModule.cc.
{ accumulated_output << input; }
void PLearn::LogaddOnBagsModule::fpropOutput | ( | Vec & | output | ) | [virtual] |
Reimplemented from PLearn::OnBagsModule.
Definition at line 102 of file LogaddOnBagsModule.cc.
References PLearn::TVec< T >::resize().
{ output.resize( output_size ); output << accumulated_output; }
OptionList & PLearn::LogaddOnBagsModule::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::OnBagsModule.
Definition at line 52 of file LogaddOnBagsModule.cc.
OptionMap & PLearn::LogaddOnBagsModule::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::OnBagsModule.
Definition at line 52 of file LogaddOnBagsModule.cc.
RemoteMethodMap & PLearn::LogaddOnBagsModule::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::OnBagsModule.
Definition at line 52 of file LogaddOnBagsModule.cc.
void PLearn::LogaddOnBagsModule::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::OnBagsModule.
Definition at line 82 of file LogaddOnBagsModule.cc.
References PLearn::deepCopyField().
{ inherited::makeDeepCopyFromShallowCopy(copies); deepCopyField(accumulated_output, copies); }
Reimplemented from PLearn::OnBagsModule.
Definition at line 79 of file LogaddOnBagsModule.h.
Vec PLearn::LogaddOnBagsModule::accumulated_output [protected] |
Definition at line 89 of file LogaddOnBagsModule.h.