UESMANN CPP  1.0
Reference implementation of UESMANN
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
OutputBlendingNet Class Reference

A modulatory network architecture which uses two plain backprop networks, each of which is trained separately. When the network is run, each subnetwork is run and the output generated by interpolating between the subnet outputs. More...

#include <obnet.hpp>

Inheritance diagram for OutputBlendingNet:
Inheritance graph
[legend]
Collaboration diagram for OutputBlendingNet:
Collaboration graph
[legend]

Public Member Functions

 OutputBlendingNet (int nlayers, const int *layerCounts)
 Constructor - does not initialise the weights to random values so that we can reinitialise networks. More...
 
virtual ~OutputBlendingNet ()
 destructor to delete subnets and outputs More...
 
virtual int getLayerSize (int n) const
 Get the number of nodes in a given layer. More...
 
virtual int getLayerCount () const
 Get the number of layers. More...
 
virtual void setH (double h)
 Set the modulator level for subsequent runs and training of this network. More...
 
virtual double getH () const
 get the modulator level More...
 
virtual void setInputs (double *d)
 Set the inputs to the network before running or training. More...
 
virtual double * getOutputs () const
 Get the outputs after running. More...
 
virtual int getDataSize () const
 Get the length of the serialised data block for this network. More...
 
virtual void save (double *buf) const
 Serialize the data (not including any network type magic number or layer/node counts) to the given memory (which must be of sufficient size). More...
 
virtual void load (double *buf)
 Given that the pointer points to a data block of the correct size for the current network, copy the parameters from that data block into the current network overwriting the current parameters. More...
 
- Public Member Functions inherited from Net
virtual ~Net ()
 virtual destructor which does nothing More...
 
void setSeed (long seed)
 Set this network's random number generator, which is used for weight initialisation done at the start of training. More...
 
int getInputCount () const
 get the number of inputs More...
 
int getOutputCount () const
 get the number of outputs More...
 
double * run (double *in)
 Run the network on some data. More...
 
double test (ExampleSet &examples, int start=0, int num=-1)
 Test a network. Runs the network over a set of examples and returns the mean MSE for all outputs

\[ \frac{1}{N\cdot N_{outs}}\sum^N_{e \in Examples} \sum_{i=0}^{N_{outs}} (e_o(i) - e_y(i))^2 \]

where $N$ is the number of examples, $N_{outs}$ is the number of outputs, $e_o(i)$ is network's output for example $e$, and $e_y(i)$ is the desired output for the same example. More...

 
double trainSGD (ExampleSet &examples, SGDParams &params)
 Train using stochastic gradient descent. Note that cross-validation parameters are slightly different from those given in the thesis. Here we give the number of slices and number of examples per slice; in the thesis we give the total number of examples to be held out and the number of slices. More...
 

Protected Member Functions

virtual void initWeights (double initr)
 initialise weights to random values More...
 
virtual void update ()
 Update the two networks, and interpolate linearly between the outputs with the modulator. More...
 
virtual double trainBatch (ExampleSet &ex, int start, int num, double eta)
 Train the network - see Net::trainBatch for more details, but this version is only suitable for SGD; it can only accept one example. More...
 
- Protected Member Functions inherited from Net
 Net (NetType tp)
 Constructor - protected because others inherit it and it's not used directly. More...
 
double drand (double mn, double mx)
 get a random number using this net's PRNG data More...
 

Protected Attributes

Netnet0
 the network trained by h=0 examples More...
 
Netnet1
 the network trained by h=1 examples More...
 
double * interpolatedOutputs
 the interpolated result after update() More...
 
double lastError = -1
 

Additional Inherited Members

- Public Attributes inherited from Net
NetType type
 type of the network, used for load/save More...
 
drand48_data rd
 PRNG data (thread safe) More...
 

Detailed Description

A modulatory network architecture which uses two plain backprop networks, each of which is trained separately. When the network is run, each subnetwork is run and the output generated by interpolating between the subnet outputs.

Definition at line 18 of file obnet.hpp.

Constructor & Destructor Documentation

OutputBlendingNet::OutputBlendingNet ( int  nlayers,
const int *  layerCounts 
)
inline

Constructor - does not initialise the weights to random values so that we can reinitialise networks.

Parameters
nlayersnumber of layers
layerCountsarray of layer counts

Definition at line 33 of file obnet.hpp.

virtual OutputBlendingNet::~OutputBlendingNet ( )
inlinevirtual

destructor to delete subnets and outputs

Definition at line 44 of file obnet.hpp.

Member Function Documentation

virtual int OutputBlendingNet::getDataSize ( ) const
inlinevirtual

Get the length of the serialised data block for this network.

Returns
the size in doubles

Implements Net.

Definition at line 80 of file obnet.hpp.

virtual double OutputBlendingNet::getH ( ) const
inlinevirtual

get the modulator level

Implements Net.

Definition at line 62 of file obnet.hpp.

virtual int OutputBlendingNet::getLayerCount ( ) const
inlinevirtual

Get the number of layers.

Implements Net.

Definition at line 54 of file obnet.hpp.

virtual int OutputBlendingNet::getLayerSize ( int  n) const
inlinevirtual

Get the number of nodes in a given layer.

Parameters
nlayer number

Implements Net.

Definition at line 50 of file obnet.hpp.

virtual double* OutputBlendingNet::getOutputs ( ) const
inlinevirtual

Get the outputs after running.

Returns
pointer to the output layer outputs

Implements Net.

Definition at line 75 of file obnet.hpp.

virtual void OutputBlendingNet::initWeights ( double  initr)
inlineprotectedvirtual

initialise weights to random values

Parameters
initrrange of weights [-n,n], or -1 for Bishop's rule.

Implements Net.

Definition at line 104 of file obnet.hpp.

virtual void OutputBlendingNet::load ( double *  buf)
inlinevirtual

Given that the pointer points to a data block of the correct size for the current network, copy the parameters from that data block into the current network overwriting the current parameters.

Parameters
bufthe buffer to load the data from, must be at least getDataSize() doubles

Implements Net.

Definition at line 92 of file obnet.hpp.

virtual void OutputBlendingNet::save ( double *  buf) const
inlinevirtual

Serialize the data (not including any network type magic number or layer/node counts) to the given memory (which must be of sufficient size).

Parameters
bufthe buffer to save the data, must be at least getDataSize() doubles

Implements Net.

Definition at line 85 of file obnet.hpp.

virtual void OutputBlendingNet::setH ( double  h)
inlinevirtual

Set the modulator level for subsequent runs and training of this network.

Implements Net.

Definition at line 58 of file obnet.hpp.

virtual void OutputBlendingNet::setInputs ( double *  d)
inlinevirtual

Set the inputs to the network before running or training.

Parameters
darray of doubles, the size of the input layer

Implements Net.

Definition at line 68 of file obnet.hpp.

virtual double OutputBlendingNet::trainBatch ( ExampleSet ex,
int  start,
int  num,
double  eta 
)
inlineprotectedvirtual

Train the network - see Net::trainBatch for more details, but this version is only suitable for SGD; it can only accept one example.

Bug:
can only use SGD for now; how this works in batching could be tricky.

Implements Net.

Definition at line 133 of file obnet.hpp.

virtual void OutputBlendingNet::update ( )
inlineprotectedvirtual

Update the two networks, and interpolate linearly between the outputs with the modulator.

Implements Net.

Definition at line 113 of file obnet.hpp.

Member Data Documentation

double* OutputBlendingNet::interpolatedOutputs
protected

the interpolated result after update()

Definition at line 102 of file obnet.hpp.

double OutputBlendingNet::lastError = -1
protected

Definition at line 126 of file obnet.hpp.

Net* OutputBlendingNet::net0
protected

the network trained by h=0 examples

Definition at line 100 of file obnet.hpp.

Net* OutputBlendingNet::net1
protected

the network trained by h=1 examples

Definition at line 101 of file obnet.hpp.


The documentation for this class was generated from the following file: