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

TrainingSet Class Reference

This is an abstraction for the set of patterns which are used to "train" a network. More...

#include <TrainingSet.h>

List of all members.

Public Member Functions

 TrainingSet (uint in, uint out)
 Create an empty training set.

 TrainingSet (const std::string &filename, int file_type=TEXT_FILE)
 Create a tranining set from a file.

virtual ~TrainingSet ()
void addIOpair (real *input, real *output)
 Add an input and correspoding output vector.

void addIOpair (const Vector &input, const Vector &output)
 Add an input and corresponding output vector
Exceptions:
Exception If the input vector size is not the same as getInputSize() or the output vector size is not the same as getOutputSize().


void addIOpair (const Vector &input)
 version without output - for unsipervised architectures.. Uses output dim 0

virtual void initialize ()
 Initialize the training set so that the first call to getNextPair() gives the first I/O pair stored.

virtual bool epochOver () const
 Has a cycle through all input/output pairs been completed?

virtual uint getSize () const
 The number of input/desired-output vector pairs in the training set.

virtual uint getInputSize () const
 The size of an input vector.

virtual uint getOutputSize () const
 The size of an output vector.

virtual void getNextPair (Vector &input, Vector &desired)
 Returns the next input/output vector pair.

virtual void save (const std::string &filename, int file_type=TEXT_FILE)
 Saves the training set to a file.

 operator std::string () const
 debugging info - not to be confused with operator<< !

virtual const char * getClassName () const
 Returns "TrainingSet".

void shuffle ()
 Randomly changes order of stored pairs.

TrainingSet operator+ (const TrainingSet &ts) const
 Weird TrainingSet arithmetics.

TrainingSetoperator+= (const TrainingSet &ts)
TrainingSet xform (XformFunction ix, XformFunction ox, uint resI, uint resO)
TrainingSet xform (XformFunction ix, XformFunction ox)
TrainingSet xform (XformFunction ix, uint resI)
 only the input part

TrainingSet xform (XformFunction ix)
 keep dimensions

TrainingSet mixedXform (const TSTransformer &xf)
 The transformer functions get.


Protected Member Functions

void save_binary (const std::string &filename)
 Save the training set in binary format to the given filename.

void save_text (const std::string &filename)
 Save the file in text format to the given filename.

void load_binary (const std::string &filename)
 Load from a binary file.

void load_text (const std::string &filename)
 Load from a text file.


Protected Attributes

std::vector< Vector_inputs
 The set of input vectors.

std::vector< Vector_outputs
 The set of corresponding desired output vectors.

std::vector< Vector >::iterator _inputIter
 An iterator through the input vectors.

std::vector< Vector >::iterator _outputIter
 Iterator through the output vectors.

uint _nInputs
 Size of an input vector.

uint _nOutputs
 Size of an output vector.


Friends

std::ostream & operator<< (std::ostream &s, TrainingSet &T)
 Allows you to print the TrainingSet onto a stream.


Detailed Description

This is an abstraction for the set of patterns which are used to "train" a network.

It will contain sets of input and corresponding desired-output vectors which will be used by the training algorithms of supervised networks, such as the MultiLayerNetwork and RadialBasisNetwork

You can save TrainingSets into a file. The file can be text, a simple format so that you can construct the file from other programs as well, or the file can be a binary file which is understood only by this library. Binary files are generally smaller and quicker to load.

You can use utilities provided with the library distribution to convert from one format to the other.


Constructor & Destructor Documentation

TrainingSet uint  in,
uint  out
 

Create an empty training set.

Parameters:
in The size of an input vector
out The size of an output vector

TrainingSet const std::string &  filename,
int  file_type = TEXT_FILE
 

Create a tranining set from a file.

Parameters:
filename The name of the file
file_type The type of the file (annie::BINARY_FILE) or (annie::TEXT_FILE). TEXT_FILE by default TODO: remake this constructor - TrainingSet(0,0) calls it :-)

virtual ~TrainingSet  )  [virtual]
 


Member Function Documentation

void addIOpair const Vector input  ) 
 

version without output - for unsipervised architectures.. Uses output dim 0

void addIOpair const Vector input,
const Vector output
 

Add an input and corresponding output vector

Exceptions:
Exception If the input vector size is not the same as getInputSize() or the output vector size is not the same as getOutputSize().

void addIOpair real input,
real output
 

Add an input and correspoding output vector.

virtual bool epochOver  )  const [virtual]
 

Has a cycle through all input/output pairs been completed?

Returns:
true if all input/output pairs have been seen through getNextPair
See also:
getNextPair

initialize

virtual const char* getClassName  )  const [virtual]
 

Returns "TrainingSet".

virtual uint getInputSize  )  const [virtual]
 

The size of an input vector.

virtual void getNextPair Vector input,
Vector desired
[virtual]
 

Returns the next input/output vector pair.

You would typically use this in a fashion somewhat like:

 TrainingSet T("trset_file");
 T.initialize();
 Vector in,out;
 while (!T.epochOver())
 {
        T.getNextPair(in,out);
        // do what you need to with in and out
 }
Parameters:
input The input vector is returned here
desired The corresponding desired output vector is returned here

virtual uint getOutputSize  )  const [virtual]
 

The size of an output vector.

virtual uint getSize  )  const [virtual]
 

The number of input/desired-output vector pairs in the training set.

virtual void initialize  )  [virtual]
 

Initialize the training set so that the first call to getNextPair() gives the first I/O pair stored.

See also:
getNextPair

void load_binary const std::string &  filename  )  [protected]
 

Load from a binary file.

void load_text const std::string &  filename  )  [protected]
 

Load from a text file.

TrainingSet mixedXform const TSTransformer xf  ) 
 

The transformer functions get.

operator std::string  )  const
 

debugging info - not to be confused with operator<< !

TrainingSet operator+ const TrainingSet ts  )  const
 

Weird TrainingSet arithmetics.

Is not supposed to be effective: the only purpose is ease of use (at least for now) OPT: passing by value

TrainingSet& operator+= const TrainingSet ts  ) 
 

virtual void save const std::string &  filename,
int  file_type = TEXT_FILE
[virtual]
 

Saves the training set to a file.

Parameters:
filename The name of the file to save the training set to
file_type The type of file to generate (annie::BINARY_FILE) or (annie::TEXT_FILE). Default is TEXT_FILE

void save_binary const std::string &  filename  )  [protected]
 

Save the training set in binary format to the given filename.

void save_text const std::string &  filename  )  [protected]
 

Save the file in text format to the given filename.

void shuffle  ) 
 

Randomly changes order of stored pairs.

TrainingSet xform XformFunction  ix  ) 
 

keep dimensions

TrainingSet xform XformFunction  ix,
uint  resI
 

only the input part

TrainingSet xform XformFunction  ix,
XformFunction  ox
[inline]
 

Here is the call graph for this function:

TrainingSet xform XformFunction  ix,
XformFunction  ox,
uint  resI,
uint  resO
 


Friends And Related Function Documentation

std::ostream& operator<< std::ostream &  s,
TrainingSet T
[friend]
 

Allows you to print the TrainingSet onto a stream.


Member Data Documentation

std::vector< Vector >::iterator _inputIter [protected]
 

An iterator through the input vectors.

std::vector< Vector > _inputs [protected]
 

The set of input vectors.

uint _nInputs [protected]
 

Size of an input vector.

uint _nOutputs [protected]
 

Size of an output vector.

std::vector< Vector >::iterator _outputIter [protected]
 

Iterator through the output vectors.

std::vector< Vector > _outputs [protected]
 

The set of corresponding desired output vectors.


The documentation for this class was generated from the following file:
Generated on Fri Jun 18 13:19:32 2004 for Annie by doxygen 1.3.5