libeblearn
|
A stack of module_1_1 modules. More...
#include <ebl_arch.h>
Public Member Functions | |
layers (bool oc=true, const char *name="layers", bool is_branch=false, bool narrow=false, intg dim=0, intg sz=0, intg offset=0) | |
virtual void | add_module (module_1_1< T, Tstate, Tstate > *module) |
virtual void | fprop (Tstate &in, Tstate &out) |
virtual void | bprop (Tstate &in, Tstate &out) |
virtual void | bbprop (Tstate &in, Tstate &out) |
virtual void | dump_fprop (Tstate &in, Tstate &out) |
virtual void | fprop (mstate< Tstate > &in, Tstate &out) |
virtual void | bprop (mstate< Tstate > &in, Tstate &out) |
virtual void | bbprop (mstate< Tstate > &in, Tstate &out) |
virtual void | dump_fprop (mstate< Tstate > &in, Tstate &out) |
virtual void | fprop (Tstate &in, mstate< Tstate > &out) |
virtual void | bprop (Tstate &in, mstate< Tstate > &out) |
virtual void | bbprop (Tstate &in, mstate< Tstate > &out) |
virtual void | dump_fprop (Tstate &in, mstate< Tstate > &out) |
virtual void | fprop (mstate< Tstate > &in, mstate< Tstate > &out) |
virtual void | bprop (mstate< Tstate > &in, mstate< Tstate > &out) |
virtual void | bbprop (mstate< Tstate > &in, mstate< Tstate > &out) |
virtual void | dump_fprop (mstate< Tstate > &in, mstate< Tstate > &out) |
virtual void | forget (forget_param_linear &fp) |
virtual void | normalize () |
virtual fidxdim | fprop_size (fidxdim &i_size) |
virtual fidxdim | bprop_size (const fidxdim &o_size) |
virtual mfidxdim | fprop_size (mfidxdim &isize) |
virtual mfidxdim | bprop_size (mfidxdim &o_size) |
virtual std::string | pretty (idxdim &isize) |
virtual std::string | pretty (mfidxdim &isize) |
virtual layers< T, Tstate > * | copy () |
Returns a deep copy of current module. | |
virtual void | swap_buffers () |
Swap the dual buffers used for memory optimization. | |
virtual uint | size () |
Return the number of layers contained in this object. | |
virtual void | clear_dx () |
virtual void | clear_ddx () |
bool | is_branch () |
Returns true if this layer is being used as a branch, false otherwise. | |
module_1_1< T, Tstate, Tstate > * | find (const char *name) |
Find first module whose name matches 'name', return NULL if not found. | |
virtual module_1_1< T, Tstate > * | last_module () |
virtual std::string | describe (uint indent=0) |
Returns a string containing describe() string of all modules. | |
virtual bool | mstate_input () |
Returns true if this module takes a multi-state as input. | |
virtual bool | mstate_output () |
Returns true if this module produces a multi-state as output. | |
virtual void | set_output_streams (std::ostream &out, std::ostream &err) |
Replace standard output streams for this module. | |
Public Attributes | |
std::vector< module_1_1< T, Tstate, Tstate > * > | modules |
std::vector< mstate< Tstate > * > | hiddens |
mstate< Tstate > * | intern_out |
Protected Attributes | |
bool | own_contents |
internal output, set if this is a branch | |
mstate< Tstate > * | hi |
mstate< Tstate > * | ho |
temporary buffer pointer | |
mstate< Tstate > * | htmp |
temporary buffer pointer | |
bool | branch |
temporary buffer pointer used for swapping | |
mstate< Tstate > * | intern_h0 |
this is a branch or not | |
mstate< Tstate > * | intern_h1 |
internal buffer 0 if branch | |
bool | branch_narrow |
internal bufer 1 if branch | |
intg | narrow_dim |
narrow input data for branch | |
intg | narrow_size |
The dimension to narrow. | |
intg | narrow_offset |
The number of slices. | |
mstate< Tstate > | msin |
The offset. | |
mstate< Tstate > | msout |
Friends | |
class | layers_gui |
A stack of module_1_1 modules.
ebl::layers< T, Tstate >::layers | ( | bool | oc = true , |
const char * | name = "layers< T, Tstate >" , |
||
bool | is_branch = false , |
||
bool | narrow = false , |
||
intg | dim = 0 , |
||
intg | sz = 0 , |
||
intg | offset = 0 |
||
) |
Constructor.
oc | If true, this class owns all its content and is responsible for deleting modules and buffers. |
is_branch | If true, this branch will not modify its input and output buffers, instead will output to public intern_out buffer. |
void ebl::layers< T, Tstate >::add_module | ( | module_1_1< T, Tstate, Tstate > * | module | ) | [virtual] |
Add a module to the stack of modules.
branch_id | If > 0, add this module to branch with this id. |
fidxdim ebl::layers< T, Tstate >::bprop_size | ( | const fidxdim & | o_size | ) | [virtual] |
given the output dimensions, returns the input dimensions. the implementation of this method helps automatic scaling of input data but is optional.
Loop through all the layers of the module, from the end to the beg.
Reimplemented from ebl::module_1_1< T, Tstate, Tstate >.
mfidxdim ebl::layers< T, Tstate >::bprop_size | ( | mfidxdim & | o_size | ) | [virtual] |
Given multiple output dimensions, returns the input dimensions. The implementation of this method helps automatic scaling of input data but is optional.
Loop through all the layers of the module, from the end to the beg.
Reimplemented from ebl::module_1_1< T, Tstate, Tstate >.
void ebl::layers< T, Tstate >::clear_ddx | ( | ) | [virtual] |
Clear the hidden's states ddx and recursively clear all branches contained in modules.
void ebl::layers< T, Tstate >::clear_dx | ( | ) | [virtual] |
Clear the hidden's states dx and recursively clear all branches contained in modules.
layers< T, Tstate > * ebl::layers< T, Tstate >::copy | ( | ) | [virtual] |
Returns a deep copy of current module.
Loop through all the modules and buffers and copy them
Reimplemented from ebl::module_1_1< T, Tstate, Tstate >.
void ebl::layers< T, Tstate >::dump_fprop | ( | mstate< Tstate > & | in, |
mstate< Tstate > & | out | ||
) | [virtual] |
Calls fprop and then dumps internal buffers, inputs and outputs into files. This can be useful for debugging.
Reimplemented from ebl::module_1_1< T, Tstate, Tstate >.
void ebl::layers< T, Tstate >::dump_fprop | ( | mstate< Tstate > & | in, |
Tstate & | out | ||
) | [virtual] |
Calls fprop and then dumps internal buffers, inputs and outputs into files. This can be useful for debugging.
Reimplemented from ebl::module_1_1< T, Tstate, Tstate >.
void ebl::layers< T, Tstate >::dump_fprop | ( | Tstate & | in, |
Tstate & | out | ||
) | [virtual] |
Calls fprop and then dumps internal buffers, inputs and outputs into files. This can be useful for debugging.
Reimplemented from ebl::module_1_1< T, Tstate, Tstate >.
void ebl::layers< T, Tstate >::dump_fprop | ( | Tstate & | in, |
mstate< Tstate > & | out | ||
) | [virtual] |
Calls fprop and then dumps internal buffers, inputs and outputs into files. This can be useful for debugging.
Reimplemented from ebl::module_1_1< T, Tstate, Tstate >.
void ebl::layers< T, Tstate >::fprop | ( | Tstate & | in, |
Tstate & | out | ||
) | [virtual] |
Pre-determine the order of hidden buffers to use only 2 buffers in order to reduce memory footprint. This returns true if outputs is actually put in out, false if it's in in.
Reimplemented from ebl::module_1_1< T, Tstate, Tstate >.
fidxdim ebl::layers< T, Tstate >::fprop_size | ( | fidxdim & | i_size | ) | [virtual] |
given the input dimensions, modifies it to be compliant with module's architecture, and returns the output dimensions corresponding to modified input dimensions. the implementation of this method helps automatic scaling of input data but is optional.
Loop through all the layers of the module, and update output size accordingly.
Recompute the input size to be compliant with the output
Reimplemented from ebl::module_1_1< T, Tstate, Tstate >.
mfidxdim ebl::layers< T, Tstate >::fprop_size | ( | mfidxdim & | isize | ) | [virtual] |
Modifies multi-input dimensions 'isize' to be compliant with module's architecture, and returns corresponding output dimensions. Implementation of this method helps automatic scaling of input data but is optional.
Loop through all the layers of the module, and update output size accordingly.
Recompute the input size to be compliant with the output
Reimplemented from ebl::module_1_1< T, Tstate, Tstate >.
module_1_1< T, Tstate, Tstate > * ebl::layers< T, Tstate >::last_module | ( | ) | [virtual] |
Returns the last module contained in this module, or itself if composed of only 1 module.
Reimplemented from ebl::module_1_1< T, Tstate, Tstate >.
std::string ebl::layers< T, Tstate >::pretty | ( | idxdim & | isize | ) | [virtual] |
Prints the forward transformation of dimensions in a string and return it. This method calls fprop_size to determine the output size given the input.
Reimplemented from ebl::module_1_1< T, Tstate, Tstate >.
std::string ebl::layers< T, Tstate >::pretty | ( | mfidxdim & | isize | ) | [virtual] |
Prints the forward transformation of multi-dimensions in a string and return it. This method calls fprop_size to determine the output size given the input.
Loop through all the layers of the module, and update output size accordingly.
Reimplemented from ebl::module_1_1< T, Tstate, Tstate >.