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

PLearn::NeuralNet Class Reference

#include <NeuralNet.h>

Inheritance diagram for PLearn::NeuralNet:

Inheritance graph
[legend]
Collaboration diagram for PLearn::NeuralNet:

Collaboration graph
[legend]
List of all members.

Public Types

typedef Learner inherited

Public Member Functions

 NeuralNet ()
virtual ~NeuralNet ()
 PLEARN_DECLARE_OBJECT (NeuralNet)
virtual void build ()
 **** SUBCLASS WRITING: **** This method should be redefined in subclasses, to just call inherited::build() and then build_()

virtual void forget ()
void initializeParams ()
virtual void train (VMat training_set)
virtual void use (const Vec &inputvec, Vec &prediction)
virtual int costsize () const
 **** SUBCLASS WRITING: should be re-defined if user re-defines computeCost default version returns

virtual Array< stringcostNames () const
virtual Array< stringtestResultsNames ()
virtual void useAndCost (const Vec &inputvec, const Vec &targetvec, Vec outputvec, Vec costvec)
 By default this function calls use(input, output) and then computeCost(input, target, output, cost) So you can overload computeCost to change cost computation.

void computeCost (const Vec &inputvec, const Vec &targetvec, const Vec &outputvec, const Vec &costvec)
 computes the cost vec, given input, target and output The default version applies the declared CostFunc's on the (output,target) pair, putting the cost computed for each CostFunc in an element of the cost vector.

virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)

Public Attributes

Func f
Func costf
Func output_and_target_to_cost
int nhidden
int nhidden2
real weight_decay
real bias_decay
real layer1_weight_decay
real layer1_bias_decay
real layer2_weight_decay
real layer2_bias_decay
real output_layer_weight_decay
real output_layer_bias_decay
real direct_in_to_out_weight_decay
bool global_weight_decay
bool direct_in_to_out
string output_transfer_func
int iseed
Array< stringcost_funcs
 a list of cost functions to use in the form "[ cf1; cf2; cf3; ... ]"

real semisupervised_flatten_factor
Vec semisupervised_prior
PP< Optimizeroptimizer
int batch_size
int nepochs
string saveparams
Array< Vecnormalization

Static Protected Member Functions

void declareOptions (OptionList &ol)
 redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options) ( see the declareOption function further down)


Protected Attributes

Var input
Var target
Var costweights
Var target_and_weights
Var w1
Var w2
Var wout
Var wdirect
Var output
VarArray costs
Var cost
VarArray params
Vec paramsvalues
Vec initial_paramsvalues

Private Member Functions

void build_ ()

Member Typedef Documentation

typedef Learner PLearn::NeuralNet::inherited
 

Reimplemented from PLearn::Learner.

Definition at line 81 of file NeuralNet.h.


Constructor & Destructor Documentation

PLearn::NeuralNet::NeuralNet  ) 
 

Definition at line 84 of file NeuralNet.cc.

PLearn::NeuralNet::~NeuralNet  )  [virtual]
 

Definition at line 105 of file NeuralNet.cc.


Member Function Documentation

void PLearn::NeuralNet::build  )  [virtual]
 

**** SUBCLASS WRITING: **** This method should be redefined in subclasses, to just call inherited::build() and then build_()

Reimplemented from PLearn::Learner.

Definition at line 200 of file NeuralNet.cc.

References build_().

void PLearn::NeuralNet::build_  )  [private]
 

**** SUBCLASS WRITING: **** The build_ and build methods should be redefined in subclasses build_ should do the actual building of the Learner according to build options (member variables) previously set. (These may have been set by hand, by a constructor, by the load method, or by setOption) As build() may be called several times (after changing options, to "rebuild" an object with different build options), make sure your implementation can handle this properly.

Reimplemented from PLearn::Learner.

Definition at line 206 of file NeuralNet.cc.

References PLearn::affine_transform(), PLearn::affine_transform_weight_penalty(), PLearn::TVec< Var >::append(), bias_decay, c_str(), PLearn::classification_loss(), cost, cost_funcs, costf, costs, costweights, PLearn::cross_entropy(), direct_in_to_out, direct_in_to_out_weight_decay, PLearn::exp(), f, PLearn::TVec< T >::fill(), PLearn::hconcat(), PLearn::ifThenElse(), initial_paramsvalues, initializeParams(), input, PLearn::Learner::inputsize(), PLearn::isMissing(), PLearn::TVec< Var >::isNull(), k, layer1_bias_decay, layer1_weight_decay, layer2_bias_decay, layer2_weight_decay, PLearn::TVec< T >::length(), PLearn::TVec< Vec >::length(), PLearn::log_softmax(), PLearn::VarArray::makeSharedValue(), MISSING_VALUE, PLearn::multiclass_loss(), PLearn::neg_log_pi(), PLearn::VarArray::nelems(), PLearn::newObject(), nhidden, nhidden2, normalization, PLearn::onehot_squared_loss(), output, output_and_target_to_cost, output_layer_bias_decay, output_layer_weight_decay, output_transfer_func, PLearn::Learner::outputsize(), params, paramsvalues, PLERROR, PLWARNING, PLearn::TVec< T >::resize(), PLearn::TVec< Var >::resize(), semisupervised_flatten_factor, semisupervised_prior, PLearn::sigmoid(), PLearn::TVec< T >::size(), PLearn::TVec< Var >::size(), PLearn::TVec< string >::size(), PLearn::softmax(), PLearn::softplus(), PLearn::sum(), PLearn::sumsquare(), PLearn::tanh(), target, target_and_weights, PLearn::Learner::targetsize(), PLearn::transposeProduct(), PLearn::var(), w1, w2, wdirect, weight_decay, PLearn::weighted_sumsquare(), PLearn::Learner::weightsize(), and wout.

Referenced by build().

void PLearn::NeuralNet::computeCost const Vec inputvec,
const Vec targetvec,
const Vec outputvec,
const Vec costvec
[virtual]
 

computes the cost vec, given input, target and output The default version applies the declared CostFunc's on the (output,target) pair, putting the cost computed for each CostFunc in an element of the cost vector.

If you overload this method in subclasses (e.g. to compute a cost that depends on the internal elements of the model), you must also redefine costsize() and costNames() accordingly.

Reimplemented from PLearn::Learner.

Definition at line 494 of file NeuralNet.cc.

References output_and_target_to_cost.

Array< string > PLearn::NeuralNet::costNames  )  const [virtual]
 

returns an Array of strings for the names of the components of the cost. Default version returns the info() strings of the cost functions in test_costfuncs

Reimplemented from PLearn::Learner.

Definition at line 410 of file NeuralNet.cc.

References cost_funcs.

Referenced by testResultsNames().

int PLearn::NeuralNet::costsize  )  const [virtual]
 

**** SUBCLASS WRITING: should be re-defined if user re-defines computeCost default version returns

Reimplemented from PLearn::Learner.

Definition at line 415 of file NeuralNet.cc.

References cost.

void PLearn::NeuralNet::declareOptions OptionList ol  )  [static, protected]
 

redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options) ( see the declareOption function further down)

ex: static void declareOptions(OptionList& ol) { declareOption(ol, "inputsize", &MyObject::inputsize_, OptionBase::buildoption, "the size of the input\n it must be provided"); declareOption(ol, "weights", &MyObject::weights, OptionBase::learntoption, "the learnt model weights"); inherited::declareOptions(ol); }

Reimplemented from PLearn::Learner.

Definition at line 109 of file NeuralNet.cc.

References PLearn::declareOption(), and PLearn::OptionList.

void PLearn::NeuralNet::forget  )  [virtual]
 

*** SUBCLASS WRITING: *** This method should be called AFTER or inside the build method, e.g. in order to re-initialize parameters. It should put the Learner in a 'fresh' state, not being influenced by any past call to train (everything learned is forgotten!).

Reimplemented from PLearn::Learner.

Definition at line 499 of file NeuralNet.cc.

References initial_paramsvalues, initializeParams(), and params.

void PLearn::NeuralNet::initializeParams  ) 
 

Definition at line 441 of file NeuralNet.cc.

References direct_in_to_out, PLearn::fill_random_normal(), PLearn::Learner::inputsize(), iseed, PLearn::manual_seed(), nhidden, nhidden2, PLearn::seed(), w1, w2, wdirect, and wout.

Referenced by build_(), and forget().

void PLearn::NeuralNet::makeDeepCopyFromShallowCopy CopiesMap copies  )  [virtual]
 

Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be. Typical implementation:

void CLASS_OF_THIS::makeDeepCopyFromShallowCopy(CopiesMap& copies) { SUPERCLASS_OF_THIS::makeDeepCopyFromShallowCopy(copies); member_ptr = member_ptr->deepCopy(copies); member_smartptr = member_smartptr->deepCopy(copies); member_mat.makeDeepCopyFromShallowCopy(copies); member_vec.makeDeepCopyFromShallowCopy(copies); ... }

Reimplemented from PLearn::Learner.

Definition at line 508 of file NeuralNet.cc.

References PLearn::CopiesMap, PLearn::deepCopyField(), and optimizer.

PLearn::NeuralNet::PLEARN_DECLARE_OBJECT NeuralNet   ) 
 

virtual Array<string> PLearn::NeuralNet::testResultsNames  )  [inline, virtual]
 

Definition at line 144 of file NeuralNet.h.

References costNames().

void PLearn::NeuralNet::train VMat  training_set  )  [virtual]
 

*** SUBCLASS WRITING: *** Does the actual training. Subclasses must implement this method. The method should upon entry, call setTrainingSet(training_set); Make sure that a if(measure(step, objective_value)) is done after each training step, and that training is stopped if it returned true

Implements PLearn::Learner.

Definition at line 418 of file NeuralNet.cc.

References batch_size, cost, costf, input, PLearn::VMat::length(), PLearn::meanOf(), nepochs, optimizer, output_and_target_to_cost, params, paramsvalues, PLearn::save(), saveparams, and target_and_weights.

void PLearn::NeuralNet::use const Vec inputvec,
Vec prediction
[virtual]
 

*** SUBCLASS WRITING: *** Uses a trained decider on input, filling output. If the cost should also be computed, then the user should call useAndCost instead of this method.

Implements PLearn::Learner.

Definition at line 484 of file NeuralNet.cc.

References f.

void PLearn::NeuralNet::useAndCost const Vec inputvec,
const Vec targetvec,
Vec  outputvec,
Vec  costvec
[virtual]
 

By default this function calls use(input, output) and then computeCost(input, target, output, cost) So you can overload computeCost to change cost computation.

Reimplemented from PLearn::Learner.

Definition at line 489 of file NeuralNet.cc.

References costf.


Member Data Documentation

int PLearn::NeuralNet::batch_size
 

Definition at line 116 of file NeuralNet.h.

Referenced by train().

real PLearn::NeuralNet::bias_decay
 

Definition at line 91 of file NeuralNet.h.

Referenced by build_().

Var PLearn::NeuralNet::cost [protected]
 

Definition at line 67 of file NeuralNet.h.

Referenced by build_(), costsize(), and train().

Array<string> PLearn::NeuralNet::cost_funcs
 

a list of cost functions to use in the form "[ cf1; cf2; cf3; ... ]"

Definition at line 109 of file NeuralNet.h.

Referenced by build_(), and costNames().

Func PLearn::NeuralNet::costf
 

Definition at line 76 of file NeuralNet.h.

Referenced by build_(), train(), and useAndCost().

VarArray PLearn::NeuralNet::costs [protected]
 

Definition at line 66 of file NeuralNet.h.

Referenced by build_().

Var PLearn::NeuralNet::costweights [protected]
 

Definition at line 58 of file NeuralNet.h.

Referenced by build_().

bool PLearn::NeuralNet::direct_in_to_out
 

Definition at line 101 of file NeuralNet.h.

Referenced by build_(), and initializeParams().

real PLearn::NeuralNet::direct_in_to_out_weight_decay
 

Definition at line 98 of file NeuralNet.h.

Referenced by build_().

Func PLearn::NeuralNet::f
 

Definition at line 75 of file NeuralNet.h.

Referenced by build_(), and use().

bool PLearn::NeuralNet::global_weight_decay
 

Definition at line 100 of file NeuralNet.h.

Vec PLearn::NeuralNet::initial_paramsvalues [protected]
 

Definition at line 72 of file NeuralNet.h.

Referenced by build_(), and forget().

Var PLearn::NeuralNet::input [protected]
 

Definition at line 56 of file NeuralNet.h.

Referenced by build_(), and train().

int PLearn::NeuralNet::iseed
 

Definition at line 103 of file NeuralNet.h.

Referenced by initializeParams().

real PLearn::NeuralNet::layer1_bias_decay
 

Definition at line 93 of file NeuralNet.h.

Referenced by build_().

real PLearn::NeuralNet::layer1_weight_decay
 

Definition at line 92 of file NeuralNet.h.

Referenced by build_().

real PLearn::NeuralNet::layer2_bias_decay
 

Definition at line 95 of file NeuralNet.h.

Referenced by build_().

real PLearn::NeuralNet::layer2_weight_decay
 

Definition at line 94 of file NeuralNet.h.

Referenced by build_().

int PLearn::NeuralNet::nepochs
 

Definition at line 119 of file NeuralNet.h.

Referenced by train().

int PLearn::NeuralNet::nhidden
 

Definition at line 87 of file NeuralNet.h.

Referenced by build_(), and initializeParams().

int PLearn::NeuralNet::nhidden2
 

Definition at line 88 of file NeuralNet.h.

Referenced by build_(), and initializeParams().

Array<Vec> PLearn::NeuralNet::normalization
 

Definition at line 123 of file NeuralNet.h.

Referenced by build_().

PP<Optimizer> PLearn::NeuralNet::optimizer
 

Definition at line 114 of file NeuralNet.h.

Referenced by makeDeepCopyFromShallowCopy(), and train().

Var PLearn::NeuralNet::output [protected]
 

Definition at line 65 of file NeuralNet.h.

Referenced by build_().

Func PLearn::NeuralNet::output_and_target_to_cost
 

Definition at line 77 of file NeuralNet.h.

Referenced by build_(), computeCost(), and train().

real PLearn::NeuralNet::output_layer_bias_decay
 

Definition at line 97 of file NeuralNet.h.

Referenced by build_().

real PLearn::NeuralNet::output_layer_weight_decay
 

Definition at line 96 of file NeuralNet.h.

Referenced by build_().

string PLearn::NeuralNet::output_transfer_func
 

Definition at line 102 of file NeuralNet.h.

Referenced by build_().

VarArray PLearn::NeuralNet::params [protected]
 

Definition at line 69 of file NeuralNet.h.

Referenced by build_(), forget(), and train().

Vec PLearn::NeuralNet::paramsvalues [protected]
 

Definition at line 71 of file NeuralNet.h.

Referenced by build_(), and train().

string PLearn::NeuralNet::saveparams
 

Definition at line 121 of file NeuralNet.h.

Referenced by train().

real PLearn::NeuralNet::semisupervised_flatten_factor
 

Definition at line 110 of file NeuralNet.h.

Referenced by build_().

Vec PLearn::NeuralNet::semisupervised_prior
 

Definition at line 111 of file NeuralNet.h.

Referenced by build_().

Var PLearn::NeuralNet::target [protected]
 

Definition at line 57 of file NeuralNet.h.

Referenced by build_().

Var PLearn::NeuralNet::target_and_weights [protected]
 

Definition at line 59 of file NeuralNet.h.

Referenced by build_(), and train().

Var PLearn::NeuralNet::w1 [protected]
 

Definition at line 60 of file NeuralNet.h.

Referenced by build_(), and initializeParams().

Var PLearn::NeuralNet::w2 [protected]
 

Definition at line 61 of file NeuralNet.h.

Referenced by build_(), and initializeParams().

Var PLearn::NeuralNet::wdirect [protected]
 

Definition at line 63 of file NeuralNet.h.

Referenced by build_(), and initializeParams().

real PLearn::NeuralNet::weight_decay
 

Definition at line 90 of file NeuralNet.h.

Referenced by build_().

Var PLearn::NeuralNet::wout [protected]
 

Definition at line 62 of file NeuralNet.h.

Referenced by build_(), and initializeParams().


The documentation for this class was generated from the following files:
Generated on Tue Aug 17 16:27:27 2004 for PLearn by doxygen 1.3.7