4 #include "dnf/Neuron.h"
24 DNF(
const int NLAYERS,
28 signalDelayLineLength(noiseDelayLineLength / 2),
29 signal_delayLine(signalDelayLineLength),
30 nNeurons(new int[NLAYERS]),
31 noise_delayLine(new double[noiseDelayLineLength]) {
33 double b = exp(log(noiseDelayLineLength)/(NLAYERS-1));
34 for(
int i=0;i<NLAYERS;i++) {
35 nNeurons[i] = ceil(noiseDelayLineLength / pow(b,i));
36 if (i == (NLAYERS-1)) nNeurons[i] = 1;
40 NNO =
new Net(NLAYERS, nNeurons, noiseDelayLineLength, 0,
"");
43 for(
int i=0;i<NLAYERS;i++) {
45 fprintf(stderr,
"Layer %d has %d neurons. act = %d\n",i,nNeurons[i],am);
55 double filter(
double signal,
double noise) {
56 signal_delayLine.push_back(signal);
57 const double delayed_signal = signal_delayLine[0];
59 for (
int i = noiseDelayLineLength-1 ; i > 0; i--) {
60 noise_delayLine[i] = noise_delayLine[i-1];
62 noise_delayLine[0] = noise / (double)noiseDelayLineLength;
70 f_nn = delayed_signal - remover;
93 return signalDelayLineLength;
102 return signal_delayLine[0];
128 delete[] noise_delayLine;
133 int noiseDelayLineLength;
134 int signalDelayLineLength;
135 boost::circular_buffer<double> signal_delayLine;
136 double* noise_delayLine;
DNF(const int NLAYERS, const int numTaps, double fs, Neuron::actMethod am=Neuron::Act_Tanh)
Constructor which sets up the delay lines, network layers and also calculates the number of neurons p...
Definition: dnf.h:24
void setError(double _leadError)
Sets the error at the output layer to be propagated backward.
Net is the main class used to set up a neural network used for closed-loop Deep Learning.
Definition: Net.h:30
actMethod
Options for activation functions of the neuron 0 for using the logistic function 1 for using the hype...
Definition: Neuron.h:62
void updateWeights()
Requests that all layers perform one iteration of learning.
const int getSignalDelaySteps() const
Returns the length of the delay line which delays the signal polluted with noise.
Definition: dnf.h:92
~DNF()
Frees the memory used by the DNF.
Definition: dnf.h:125
const double getRemover() const
Returns the remover signal.
Definition: dnf.h:109
void setInputs(const double *_inputs, const double scale=1.0, const unsigned int offset=0, const int n=-1)
Sets the inputs to the network in each iteration of learning, needs to be placed in an infinite loop.
double getOutput(int _neuronIndex)
Allows the user to access the activation output of a specific neuron in the output layer only.
void initLayer(int _layerIndex, Neuron::weightInitMethod _wim, Neuron::biasInitMethod _bim, Neuron::actMethod _am)
Initialises each layer with specific methods for weight/bias initialisation and activation function o...
Net & getNet() const
Returns a reference to the whole neural network.
Definition: dnf.h:83
void propErrorBackward()
Propagates the error backward.
const double getOutput() const
Returns the output of the DNF: the the noise free signal.
Definition: dnf.h:118
const double getDelayedSignal() const
Returns the delayed with noise polluted signal by the delay indicated by getSignalDelaySteps().
Definition: dnf.h:101
Layer * getLayer(int _layerIndex)
Allows Net to access each layer.
Main Deep Neuronal Network main class.
Definition: dnf.h:13
double filter(double signal, double noise)
Realtime sample by sample filtering operation.
Definition: dnf.h:55
void propInputs()
It propagates the inputs forward through the network.