UESMANN CPP  1.0
Reference implementation of UESMANN
/home/travis/build/jimfinnis/uesmanncpp/hinet.hpp
Go to the documentation of this file.
1 
7 #ifndef __HINET_HPP
8 #define __HINET_HPP
9 
10 #include "data.hpp"
11 
17 class HInputNet : public BPNet {
22  double modulator;
23 
24 public:
32  HInputNet(int nlayers,const int *layerCounts) : BPNet() {
33  // replace the net type, it's not a plain net any more
35 
36  // you may have noticed that I tend to use arrays a lot rather than
37  // std::vector. Sorry, I do this without realising because I'm very,
38  // very old.
39 
40  int *ll = new int[nlayers];
41  for(int i=0;i<nlayers;i++){
42  ll[i] = layerCounts[i]; // copy the layers array
43  }
44  ll[0]++; // add an extra input
45 
46  init(nlayers,ll);
47 
48 
49  }
50 
54  virtual ~HInputNet(){
55  }
56 
57  virtual int getLayerSize(int n) const {
58  int ct = layerSizes[n];
59  // subtract one if it's the input layer, so we
60  // don't see the hidden input.
61  return (n==0)?ct-1:ct;
62  }
63 
64  virtual void setH(double h){
65  modulator = h;
66  }
67 
68  virtual double getH() const {
69  return modulator;
70  }
71 
72  virtual void setInputs(double *d) {
73  // get the number of input which are not the modulator input
74  int nins = layerSizes[0]-1;
75  for(int i=0;i<nins;i++){
76  setInput(i,*d++); // set manually
77  }
78 
79  // now set the final input
80  setInput(nins,modulator);
81  }
82 };
83 
84 
85 
86 #endif /* __HINET_HPP */
output blending
virtual void setInputs(double *d)
Set the inputs to the network before running or training.
Definition: hinet.hpp:72
void init(int nlayers, const int *layerCounts)
Initialiser for use by the main constructor and the ctors of those subclasses mentioned in BPNet() ...
Definition: bpnet.hpp:32
virtual double getH() const
get the modulator level
Definition: hinet.hpp:68
A modulatory network architecture which uses a plain backprop network with an extra input to carry th...
Definition: hinet.hpp:17
The "basic" back-propagation network using a logistic sigmoid, as described by Rumelhart, Hinton and Williams (and many others). This class is used by output blending and h-as-input networks.
Definition: bpnet.hpp:18
Contains formats for example data.
HInputNet(int nlayers, const int *layerCounts)
Constructor - does not initialise the weights to random values so that we can reinitialise networks...
Definition: hinet.hpp:32
NetType type
type of the network, used for load/save
Definition: net.hpp:49
virtual void setH(double h)
Set the modulator level for subsequent runs and training of this network.
Definition: hinet.hpp:64
virtual ~HInputNet()
destructor
Definition: hinet.hpp:54
void setInput(int n, double d)
Used to set inputs manually, typically in HInputNet.
Definition: bpnet.hpp:115
virtual int getLayerSize(int n) const
Get the number of nodes in a given layer.
Definition: hinet.hpp:57
int * layerSizes
array of layer sizes
Definition: bpnet.hpp:191