The abstract network type upon which all others are based. It's not pure virtual, in that it encapsulates some high level operations (such as the top-level training algorithm).
More...
#include <net.hpp>
|
struct | SGDParams |
| Training parameters for trainSGD(). This structure holds the parameters for the trainSGD() method, and serves as a better way of passing them than a long parameter list. All values have defaults set up by the constructor, which are given as constants. You can set parameters by hand, but there are fluent (chainable) setters for many members. More...
|
|
|
virtual void | update ()=0 |
| Run a single update of the network. More...
|
|
| 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...
|
|
virtual void | initWeights (double initr)=0 |
| initialise weights to random values More...
|
|
virtual double | trainBatch (ExampleSet &ex, int start, int num, double eta)=0 |
| Train a network for batch (or mini-batch) (or single example). More...
|
|
The abstract network type upon which all others are based. It's not pure virtual, in that it encapsulates some high level operations (such as the top-level training algorithm).
Definition at line 39 of file net.hpp.
virtual destructor which does nothing
Definition at line 47 of file net.hpp.
Constructor - protected because others inherit it and it's not used directly.
- Parameters
-
tp | network type enumeration |
Definition at line 580 of file net.hpp.
double Net::drand |
( |
double |
mn, |
|
|
double |
mx |
|
) |
| |
|
inlineprotected |
get a random number using this net's PRNG data
- Parameters
-
mn | minimum value (inclusive) |
mx | maximum value (inclusive) |
Definition at line 591 of file net.hpp.
virtual int Net::getDataSize |
( |
| ) |
const |
|
pure virtual |
Get the length of the serialised data block for this network.
- Returns
- the size in doubles
Implemented in BPNet, and OutputBlendingNet.
virtual double Net::getH |
( |
| ) |
const |
|
pure virtual |
int Net::getInputCount |
( |
| ) |
const |
|
inline |
get the number of inputs
Definition at line 75 of file net.hpp.
virtual int Net::getLayerCount |
( |
| ) |
const |
|
pure virtual |
virtual int Net::getLayerSize |
( |
int |
n | ) |
const |
|
pure virtual |
int Net::getOutputCount |
( |
| ) |
const |
|
inline |
get the number of outputs
Definition at line 82 of file net.hpp.
virtual double* Net::getOutputs |
( |
| ) |
const |
|
pure virtual |
Get the outputs after running.
- Returns
- pointer to the output layer outputs
Implemented in BPNet, and OutputBlendingNet.
virtual void Net::initWeights |
( |
double |
initr | ) |
|
|
protectedpure virtual |
initialise weights to random values
- Parameters
-
initr | range of weights [-n,n], or -1 for Bishop's rule. |
Implemented in BPNet, and OutputBlendingNet.
virtual void Net::load |
( |
double * |
buf | ) |
|
|
pure virtual |
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
-
buf | the buffer to load the data from, must be at least getDataSize() doubles |
Implemented in BPNet, and OutputBlendingNet.
double* Net::run |
( |
double * |
in | ) |
|
|
inline |
Run the network on some data.
- Parameters
-
in | pointer to the input double array |
- Returns
- pointer to the output double array
Definition at line 107 of file net.hpp.
virtual void Net::save |
( |
double * |
buf | ) |
const |
|
pure virtual |
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
-
buf | the buffer to save the data, must be at least getDataSize() doubles |
Implemented in BPNet, and OutputBlendingNet.
virtual void Net::setH |
( |
double |
h | ) |
|
|
pure virtual |
virtual void Net::setInputs |
( |
double * |
d | ) |
|
|
pure virtual |
Set the inputs to the network before running or training.
- Parameters
-
d | array of doubles, the size of the input layer |
Implemented in BPNet, HInputNet, and OutputBlendingNet.
void Net::setSeed |
( |
long |
seed | ) |
|
|
inline |
Set this network's random number generator, which is used for weight initialisation done at the start of training.
Definition at line 57 of file net.hpp.
double Net::test |
( |
ExampleSet & |
examples, |
|
|
int |
start = 0 , |
|
|
int |
num = -1 |
|
) |
| |
|
inline |
Test a network. Runs the network over a set of examples and returns the mean MSE for all outputs
where
is the number of examples,
is the number of outputs,
is network's output for example
, and
is the desired output for the same example.
- Parameters
-
examples | Example set to test (or partially test). |
start | index of example to start test at. |
num | number of examples to test (or -1 for all after start point). |
Definition at line 142 of file net.hpp.
virtual double Net::trainBatch |
( |
ExampleSet & |
ex, |
|
|
int |
start, |
|
|
int |
num, |
|
|
double |
eta |
|
) |
| |
|
protectedpure virtual |
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.
- Precondition
- Network has weights initialised to random values
- Postcondition
- The network will be set to the best network found if bestNetBuffer is set, otherwise the final network will be used.
- Exceptions
-
std::out_of_range | Too many CV examples |
std::logic_error | Trying to select best by CV when there's no CV done |
- Parameters
-
examples | training set (including cross-validation data) |
params | a filled-in SGDParams structure giving the parameters for the training. |
- Returns
- If storeBestNet is null, the MSE of the final network; otherwise the MSE of the best network found. This is done across the entire validation set if provided, or the entire training set if not.
Definition at line 428 of file net.hpp.
virtual void Net::update |
( |
| ) |
|
|
protectedpure virtual |
Run a single update of the network.
- Precondition
- input layer must be filled with values
- Postcondition
- output layer contains result
Implemented in BPNet, OutputBlendingNet, and UESNet.
PRNG data (thread safe)
Definition at line 50 of file net.hpp.
type of the network, used for load/save
Definition at line 49 of file net.hpp.
The documentation for this class was generated from the following file:
- /home/travis/build/jimfinnis/uesmanncpp/net.hpp