4 #include "NeuralNetConfig.h"
12 #include "NeuronLayer.h"
13 #include "NeuronBuilder.h"
14 #include "InputNormaliser.h"
22 class InputNormaliser;
37 typedef enum {PassthroughNormalised,GaussianNormalised} InputNormalisationSelect;
38 typedef enum {XML,PlainText} SerialisationMode;
41 NeuralNet(
const int numberOfInputs,
const std::vector<int> &numberOfNeuronsPerLayer,
NeuronBuilder *theNeuronBuilder,
bool initialiseRandomSeed=
true);
42 NeuralNet(
const int numberOfInputs,
const std::vector<std::vector<std::string> > &namedNeuronsPerLayer,
bool initialiseRandomSeed=
true);
44 NeuralNet(
const std::string &xmlfile,std::vector<NeuronBuilder *> &theNeuronBuilders,
const SerialisationMode readMode=XML);
45 NeuralNet(
const char *xmlfile,std::vector<NeuronBuilder *> &theNeuronBuilders,
const SerialisationMode readMode=XML);
46 NeuralNet(
const std::string &xmlfile,
const SerialisationMode readMode=XML);
47 NeuralNet(
const char *xmlfile,
const SerialisationMode readMode=XML);
49 void serialise(std::ostream &os)
const;
50 std::vector<double> output(
const std::vector<double> &inputValues)
const;
51 int numberOfWeights()
const;
52 int numberOfLayers()
const {
return _numberOfLayers;}
53 int numberOfInputs()
const {
return _numberOfInputs;}
54 std::vector<double> weights()
const;
55 void setWeights(
const std::vector<double> &newWeights);
57 void setTargetNormalisationOffsets(
const std::vector<double> &offsets);
58 void setTargetNormalisationRanges(
const std::vector<double> &ranges);
59 std::vector<double> targetNormalisationOffsets()
const {
return _targetNormalisationOffsets;}
60 std::vector<double> targetNormalisationRanges()
const {
return _targetNormalisationRanges;}
61 std::vector<std::pair<double,double> > networkOutputRange()
const;
62 void setSerialisationPrecision(
const int precision) {_serialisationPrecision = precision;}
63 int getSerialisationPrecision()
const {
return _serialisationPrecision;}
64 void setInputNormalisers(
const std::vector<InputNormaliser *> &theNormalisers);
65 std::vector<InputNormaliser *> inputNormalisers()
const {
return _inputNormalisers;}
66 SerialisationMode getSerialisationMode()
const {
return _serialisationMode;}
67 void setSerialisationMode(
const SerialisationMode &mode) {_serialisationMode = mode;}
70 void constructLayers(
const int numberOfInputs,
const int numberOfLayers,
const std::vector<int> &numberOfNeuronsPerLayer,
bool initialiseRandomSeed);
71 void constructLayers(
const std::vector<std::vector<std::string> > &namedLayers,
bool initialiseRandomSeed);
73 void buildFromUrl(
const std::string &url,
const std::vector<NeuronBuilder *> &theNeuronBuilders);
74 void buildFromUrl(
const std::string &url);
75 void buildFromXML(
const std::string &url,
const std::vector<NeuronBuilder *> &theNeuronBuilders);
76 void buildFromXML(
const std::string &url);
77 void buildFromPlainText(
const std::string &url,
const std::vector<NeuronBuilder *> &theNeuronBuilders);
78 void buildFromPlainText(
const std::string &url);
83 std::vector<NeuronLayer *> _theLayers;
85 std::vector<double> _targetNormalisationOffsets;
86 std::vector<double> _targetNormalisationRanges;
87 std::vector<InputNormaliser *> _inputNormalisers;
88 SerialisationMode _serialisationMode;
94 _serialisationPrecision;
101 std::ostream &operator<<(std::ostream &os,
const NeuralNet &nn);