LCFIVertex  0.7.2
NeuralNetDataSet.h
1 #ifndef NEURALNETDATASET_H
2 #define NEURALNETDATASET_H
3 
4 #include "NeuralNetConfig.h"
5 
6 #include <vector>
7 #include <utility>
8 #include <iostream>
9 #include <string>
10 
11 namespace nnet
12 {
13 class NeuralNetDataSet;
14 }
15 
16 //namespace nnet added 15/08/06 by Mark Grimes (mark.grimes@bristol.ac.uk) for the LCFI vertex package
17 namespace nnet
18 {
19 
20 class
21 #ifndef __CINT__
22 NEURALNETDLL
23 #endif
25 {
26 public:
27  NeuralNetDataSet(void);
28  NeuralNetDataSet(const std::string &fileName);
29  NeuralNetDataSet(const char *fileName);
30  ~NeuralNetDataSet(void);
31  void addDataItem(const std::vector<double> &inputData,const std::vector<double> &targetOutput);
32  void getNormalisationData(std::vector<double> &inputNormalisationDataMeans,
33  std::vector<double> &targetNormalisationDataOffsets,
34  std::vector<double> &inputNormalisationDataVariances,
35  std::vector<double> &targetNormalisationDataRanges,
36  std::vector<double> &inputNormalisationDataOffsets,
37  std::vector<double> &inputNormalisationDataRanges) const;
38  void getDataItem(const int item,std::vector<double> &inputData,std::vector<double> &targetData) const;
39  int numberOfDataItems() const { return (int)_theData.size(); }
40  void setSerialisationPrecision(const int precision) {_outputPrecision = precision;}
41 
42 protected:
43  void initialiseFromFile(const std::string &fileName);
44 
45 private:
46  typedef std::pair<std::vector<double>,std::vector<double> > DataSetItem;
47 
48  std::vector<DataSetItem> _theData;
49  std::vector<double>::size_type _inputDataSize;
50  std::vector<double>::size_type _targetDataSize;
51  mutable std::vector<double> runningInputSum;
52  mutable std::vector<double> runningInputSumSqr;
53  mutable std::vector<double> runningTargetMin;
54  mutable std::vector<double> runningTargetRange;
55  mutable std::vector<double> runningInputMin;
56  mutable std::vector<double> runningInputRange;
57  mutable bool _changed;
58 #ifndef __CINT__
59  std::streamsize
60 #else
61  int
62 #endif
63  _outputPrecision;
64 
65 public:
66  friend
67 #ifndef __CINT__
68  NEURALNETDLL
69 #endif
70  std::ostream &operator<<(std::ostream &os,const NeuralNetDataSet &ds);
71 };
72 
73 #ifndef __CINT__
74 NEURALNETDLL
75 #endif
76 std::ostream &operator<<(std::ostream &os,const NeuralNetDataSet &ds);
77 
78 }//namespace nnet
79 
80 #endif