PLearn 0.1
|
#include <NetworkConnection.h>
Public Member Functions | |
NetworkConnection () | |
Default constructor. | |
NetworkConnection (const string &the_source, const string &the_destination, bool the_propagate_gradient, bool call_build_=true) | |
Convenience constructors. | |
NetworkConnection (PP< OnlineLearningModule > the_src_module, const string &the_src_port, PP< OnlineLearningModule > the_dst_module, const string &the_dst_port, bool the_propagate_gradient, bool call_build_=true) | |
void | initialize (map< string, PP< OnlineLearningModule > > &modules) |
Initialize the connection using the list of modules provided as a map from modules' names to pointers to the modules themselves. | |
PP< OnlineLearningModule > | getSourceModule () |
Return the source module. | |
const string & | getSourcePort () |
Return the source port. | |
PP< OnlineLearningModule > | getDestinationModule () |
Return the destination module. | |
const string & | getDestinationPort () |
Return the destination port. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual NetworkConnection * | 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 void | declareOptions (OptionList &ol) |
Declares the class options. | |
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 () |
Public Attributes | |
string | source |
string | destination |
bool | propagate_gradient |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Protected Attributes | |
PP< OnlineLearningModule > | src_module |
Source module. | |
string | src_port |
Source port. | |
PP< OnlineLearningModule > | dst_module |
Destination module. | |
string | dst_port |
Destination port. | |
Private Types | |
typedef Object | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
Definition at line 48 of file NetworkConnection.h.
typedef Object PLearn::NetworkConnection::inherited [private] |
Reimplemented from PLearn::Object.
Definition at line 50 of file NetworkConnection.h.
PLearn::NetworkConnection::NetworkConnection | ( | ) |
Default constructor.
Definition at line 55 of file NetworkConnection.cc.
: propagate_gradient(true) {}
PLearn::NetworkConnection::NetworkConnection | ( | const string & | the_source, |
const string & | the_destination, | ||
bool | the_propagate_gradient, | ||
bool | call_build_ = true |
||
) |
Convenience constructors.
Definition at line 62 of file NetworkConnection.cc.
References build_().
: inherited(call_build_), source(the_source), destination(the_destination), propagate_gradient(the_propagate_gradient) { if (call_build_) build_(); }
PLearn::NetworkConnection::NetworkConnection | ( | PP< OnlineLearningModule > | the_src_module, |
const string & | the_src_port, | ||
PP< OnlineLearningModule > | the_dst_module, | ||
const string & | the_dst_port, | ||
bool | the_propagate_gradient, | ||
bool | call_build_ = true |
||
) |
Definition at line 75 of file NetworkConnection.cc.
References build_(), destination, PLASSERT, and source.
: inherited(call_build_), propagate_gradient(the_propagate_gradient), src_module(the_src_module), src_port(the_src_port), dst_module(the_dst_module), dst_port(the_dst_port) { PLASSERT( the_src_module && the_dst_module ); source = the_src_module->name + "." + the_src_port; destination = the_dst_module->name + "." + the_dst_port; if (call_build_) build_(); }
string PLearn::NetworkConnection::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 50 of file NetworkConnection.cc.
OptionList & PLearn::NetworkConnection::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 50 of file NetworkConnection.cc.
RemoteMethodMap & PLearn::NetworkConnection::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 50 of file NetworkConnection.cc.
Reimplemented from PLearn::Object.
Definition at line 50 of file NetworkConnection.cc.
Object * PLearn::NetworkConnection::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 50 of file NetworkConnection.cc.
StaticInitializer NetworkConnection::_static_initializer_ & PLearn::NetworkConnection::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 50 of file NetworkConnection.cc.
void PLearn::NetworkConnection::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::Object.
Definition at line 98 of file NetworkConnection.cc.
References PLearn::Object::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::NetworkConnection::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::Object.
Definition at line 173 of file NetworkConnection.cc.
Referenced by build(), and NetworkConnection().
{ }
string PLearn::NetworkConnection::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 50 of file NetworkConnection.cc.
void PLearn::NetworkConnection::declareOptions | ( | OptionList & | ol | ) | [static] |
Declares the class options.
Reimplemented from PLearn::Object.
Definition at line 150 of file NetworkConnection.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::Object::declareOptions(), destination, propagate_gradient, and source.
{ declareOption(ol, "source", &NetworkConnection::source, OptionBase::buildoption, "Source of the connection (of the form 'module.port')."); declareOption(ol, "destination", &NetworkConnection::destination, OptionBase::buildoption, "Destination of the connection (of the form 'module.port')."); declareOption(ol, "propagate_gradient", &NetworkConnection::propagate_gradient, OptionBase::buildoption, "Whether or not the destination should propagate its gradient to the\n" "source."); // Now call the parent class' declareOptions inherited::declareOptions(ol); }
static const PPath& PLearn::NetworkConnection::declaringFile | ( | ) | [inline, static] |
NetworkConnection * PLearn::NetworkConnection::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 50 of file NetworkConnection.cc.
PP< OnlineLearningModule > PLearn::NetworkConnection::getDestinationModule | ( | ) |
Return the destination module.
Definition at line 180 of file NetworkConnection.cc.
References dst_module, and PLASSERT_MSG.
{ PLASSERT_MSG( dst_module, "getDestinationModule() cannot be called before " "the connection is initialized"); return dst_module; }
const string & PLearn::NetworkConnection::getDestinationPort | ( | ) |
Return the destination port.
Definition at line 190 of file NetworkConnection.cc.
References dst_port, and PLASSERT_MSG.
{ PLASSERT_MSG( !dst_port.empty(), "getDestinationPort() cannot be called " "before the connection is initialized"); return dst_port; }
OptionList & PLearn::NetworkConnection::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 50 of file NetworkConnection.cc.
OptionMap & PLearn::NetworkConnection::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 50 of file NetworkConnection.cc.
RemoteMethodMap & PLearn::NetworkConnection::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 50 of file NetworkConnection.cc.
PP< OnlineLearningModule > PLearn::NetworkConnection::getSourceModule | ( | ) |
Return the source module.
Definition at line 200 of file NetworkConnection.cc.
References PLASSERT_MSG, and src_module.
{ PLASSERT_MSG( src_module, "getSourceModule() cannot be called before the " "connection is initialized"); return src_module; }
const string & PLearn::NetworkConnection::getSourcePort | ( | ) |
Return the source port.
Definition at line 210 of file NetworkConnection.cc.
References PLASSERT_MSG, and src_port.
{ PLASSERT_MSG( !src_port.empty(), "getSourcePort() cannot be called before " "the connection is initialized"); return src_port; }
void PLearn::NetworkConnection::initialize | ( | map< string, PP< OnlineLearningModule > > & | modules | ) |
Initialize the connection using the list of modules provided as a map from modules' names to pointers to the modules themselves.
The goal of the initialization is to properly set the 'src_module', 'src_port', 'dst_module' and 'dst_port' fields.
Definition at line 107 of file NetworkConnection.cc.
References PLearn::TVec< T >::append(), destination, dst_module, dst_port, PLearn::TVec< T >::find(), i, PLearn::TVec< T >::length(), PLASSERT, PLERROR, source, src_module, and src_port.
{ TVec<string> specs; specs.append(source); specs.append(destination); for (int i = 0; i < specs.length(); i++) { const string& spec = specs[i]; size_t dot_pos = spec.find('.'); if (dot_pos == string::npos) PLERROR("In NetworkConnection::initialize - Could not find a dot " "in the port specification '%s'", spec.c_str()); string module_name = spec.substr(0, dot_pos); if (modules.find(module_name) == modules.end()) PLERROR("In NetworkConnection::initialize - Could not find a " "module named '%s'", module_name.c_str()); PP<OnlineLearningModule> module = modules[module_name]; string port = spec.substr(dot_pos + 1); if (i == 0) { src_module = module; src_port = port; } else { PLASSERT( i == 1 ); dst_module = module; dst_port = port; } } }
void PLearn::NetworkConnection::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::Object.
Definition at line 139 of file NetworkConnection.cc.
References PLearn::deepCopyField(), dst_module, PLearn::Object::makeDeepCopyFromShallowCopy(), and src_module.
{ inherited::makeDeepCopyFromShallowCopy(copies); deepCopyField(src_module, copies); deepCopyField(dst_module, copies); }
Reimplemented from PLearn::Object.
Definition at line 102 of file NetworkConnection.h.
Definition at line 57 of file NetworkConnection.h.
Referenced by declareOptions(), initialize(), and NetworkConnection().
PP<OnlineLearningModule> PLearn::NetworkConnection::dst_module [protected] |
Destination module.
Definition at line 120 of file NetworkConnection.h.
Referenced by getDestinationModule(), initialize(), and makeDeepCopyFromShallowCopy().
string PLearn::NetworkConnection::dst_port [protected] |
Destination port.
Definition at line 123 of file NetworkConnection.h.
Referenced by getDestinationPort(), and initialize().
Definition at line 58 of file NetworkConnection.h.
Referenced by declareOptions().
Definition at line 56 of file NetworkConnection.h.
Referenced by declareOptions(), initialize(), and NetworkConnection().
PP<OnlineLearningModule> PLearn::NetworkConnection::src_module [protected] |
Source module.
Definition at line 114 of file NetworkConnection.h.
Referenced by getSourceModule(), initialize(), and makeDeepCopyFromShallowCopy().
string PLearn::NetworkConnection::src_port [protected] |
Source port.
Definition at line 117 of file NetworkConnection.h.
Referenced by getSourcePort(), and initialize().