UESMANN CPP  1.0
Reference implementation of UESMANN
Public Member Functions | List of all members
HInputNet Class Reference

A modulatory network architecture which uses a plain backprop network with an extra input to carry the modulator. More...

#include <hinet.hpp>

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

Public Member Functions

 HInputNet (int nlayers, const int *layerCounts)
 Constructor - does not initialise the weights to random values so that we can reinitialise networks. Uses the non-initialising constructor BPNet::BPNet(), changes the layer count and initialises. More...
 
virtual ~HInputNet ()
 destructor More...
 
virtual int getLayerSize (int n) const
 Get the number of nodes in a given layer. 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...
 
- Public Member Functions inherited from BPNet
 BPNet (int nlayers, const int *layerCounts)
 Constructor - does not initialise the weights to random values so that we can reinitialise networks. More...
 
virtual ~BPNet ()
 destructor More...
 
void setInput (int n, double d)
 Used to set inputs manually, typically in HInputNet. More...
 
virtual double * getOutputs () const
 Get the outputs after running. More...
 
virtual int getLayerCount () const
 Get the number of layers. 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...
 

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...
 
- Protected Member Functions inherited from BPNet
 BPNet ()
 Special constructor for subclasses which need to manipulate layer count before initialisation (e.g. HInputNet). More...
 
void init (int nlayers, const int *layerCounts)
 Initialiser for use by the main constructor and the ctors of those subclasses mentioned in BPNet() More...
 
virtual void initWeights (double initr)
 initialise weights to random values More...
 
double & getw (int tolayer, int toneuron, int fromneuron) const
 get the value of a weight. More...
 
double & getb (int layer, int neuron) const
 get the value of a bias More...
 
double & getavggradw (int tolayer, int toneuron, int fromneuron) const
 get the value of the gradient for a given weight More...
 
double getavggradb (int l, int n) const
 get the value of a bias gradient More...
 
void calcError (double *in, double *out)
 run a single example and calculate the errors; used in training. More...
 
virtual void update ()
 Run a single update of the network. More...
 
virtual double trainBatch (ExampleSet &ex, int start, int num, double eta)
 Train a network for batch (or mini-batch) (or single 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 inherited from BPNet
int numLayers
 number of layers, including input and output More...
 
int * layerSizes
 array of layer sizes More...
 
int largestLayerSize
 number of nodes in largest layer More...
 
double ** weights
 Array of weights as [tolayer][tonode+largestLayerSize*fromnode]. More...
 
double ** biases
 array of biases, stored as a rectangular array of [layer][node] More...
 
double ** outputs
 outputs of each layer: one array of doubles for each More...
 
double ** errors
 the error for each node, calculated by calcError() More...
 
double ** gradAvgsWeights
 average gradient for each weight (built during training) More...
 
double ** gradAvgsBiases
 average gradient for each bias (built during training) More...
 

Detailed Description

A modulatory network architecture which uses a plain backprop network with an extra input to carry the modulator.

Definition at line 17 of file hinet.hpp.

Constructor & Destructor Documentation

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

Constructor - does not initialise the weights to random values so that we can reinitialise networks. Uses the non-initialising constructor BPNet::BPNet(), changes the layer count and initialises.

Parameters
nlayersnumber of layers
layerCountsarray of layer counts

Definition at line 32 of file hinet.hpp.

virtual HInputNet::~HInputNet ( )
inlinevirtual

destructor

Definition at line 54 of file hinet.hpp.

Member Function Documentation

virtual double HInputNet::getH ( ) const
inlinevirtual

get the modulator level

Reimplemented from BPNet.

Definition at line 68 of file hinet.hpp.

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

Get the number of nodes in a given layer.

Parameters
nlayer number

Reimplemented from BPNet.

Definition at line 57 of file hinet.hpp.

virtual void HInputNet::setH ( double  h)
inlinevirtual

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

Reimplemented from BPNet.

Definition at line 64 of file hinet.hpp.

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

Set the inputs to the network before running or training.

Parameters
darray of doubles, the size of the input layer

Reimplemented from BPNet.

Definition at line 72 of file hinet.hpp.


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