HOG2
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
NN Class Reference

#include <NN.h>

Inheritance diagram for NN:
Inheritance graph
[legend]
Collaboration diagram for NN:
Collaboration graph
[legend]

Public Member Functions

 NN (int inputs, int hiddens, int outputs, double learnrate)
 
 NN (NN *)
 
 NN (FunctionApproximator *)
 
 NN (char *)
 
 ~NN ()
 
void load (const char *)
 
void load (FILE *)
 
void load (const NN *)
 
void load (const FunctionApproximator *fa)
 
void save (const char *)
 
void save (FILE *)
 
double train (std::vector< double > &input, std::vector< double > &target)
 
double * test (const std::vector< double > &input)
 
double GetInput (std::vector< double > &input, const std::vector< double > &target)
 
double train (std::vector< unsigned int > &input, std::vector< double > &target)
 
double * test (const std::vector< unsigned int > &input)
 
int getNumInputs ()
 
double getInputWeight (int inp, int outp=0)
 
void Print ()
 
- Public Member Functions inherited from FunctionApproximator
 FunctionApproximator ()
 
virtual ~FunctionApproximator ()
 
virtual void setLearnRate (double)
 
virtual double getLearnRate ()
 
void setOutputActivation (tActivation t)
 
tActivation getOutputActivation ()
 

Static Public Member Functions

static bool validSaveFile (char *fname)
 

Private Member Functions

void allocateMemory (const NN *nn=0)
 
void freeMemory ()
 
double g (double a)
 
double dg (double a)
 
double outputerr (const std::vector< double > &output, const std::vector< double > &expected, int which)
 
double internalerr (const std::vector< double > &output, const std::vector< double > &expected, int which)
 
double internalinputerr (const std::vector< double > &output, const std::vector< double > &expected, int which)
 
double error (const std::vector< double > &outputs)
 

Private Attributes

std::vector< std::vector< std::vector< double > > > weights
 
std::vector< std::vector< std::vector< double > > > updatedweights
 
std::vector< std::vector< std::vector< double > > > errors
 
std::vector< double > hidden
 
std::vector< double > output
 
int inputs
 
int hiddens
 
int outputs
 

Additional Inherited Members

- Protected Attributes inherited from FunctionApproximator
double rate
 
tActivation outputActivation
 

Detailed Description

Definition at line 7 of file NN.h.

Constructor & Destructor Documentation

◆ NN() [1/4]

NN::NN ( int  inputs,
int  hiddens,
int  outputs,
double  learnrate 
)

◆ NN() [2/4]

NN::NN ( NN nn)

◆ NN() [3/4]

NN::NN ( FunctionApproximator fa)

◆ NN() [4/4]

NN::NN ( char *  f)

Definition at line 46 of file NN.cpp.

References inputs, and load().

◆ ~NN()

NN::~NN ( )

Definition at line 30 of file NN.cpp.

References freeMemory().

Member Function Documentation

◆ allocateMemory()

void NN::allocateMemory ( const NN nn = 0)
private

Definition at line 63 of file NN.cpp.

References errors, hidden, hiddens, inputs, output, outputs, updatedweights, and weights.

Referenced by load(), and NN().

◆ dg()

double NN::dg ( double  a)
private

Definition at line 297 of file NN.cpp.

Referenced by internalerr(), internalinputerr(), and outputerr().

◆ error()

double NN::error ( const std::vector< double > &  outputs)
private

Definition at line 333 of file NN.cpp.

References output, and outputs.

Referenced by GetInput(), and train().

◆ freeMemory()

void NN::freeMemory ( )
private

Definition at line 119 of file NN.cpp.

Referenced by load(), and ~NN().

◆ g()

double NN::g ( double  a)
private

Definition at line 292 of file NN.cpp.

Referenced by test().

◆ GetInput()

double NN::GetInput ( std::vector< double > &  input,
const std::vector< double > &  target 
)
virtual

Implements FunctionApproximator.

Definition at line 413 of file NN.cpp.

References error(), hiddens, inputs, internalinputerr(), output, test(), and weights.

◆ getInputWeight()

double NN::getInputWeight ( int  inp,
int  outp = 0 
)
inlinevirtual

Reimplemented from FunctionApproximator.

Definition at line 29 of file NN.h.

References weights.

◆ getNumInputs()

int NN::getNumInputs ( )
inlinevirtual

Reimplemented from FunctionApproximator.

Definition at line 28 of file NN.h.

References inputs.

◆ internalerr()

double NN::internalerr ( const std::vector< double > &  output,
const std::vector< double > &  expected,
int  which 
)
private

Definition at line 312 of file NN.cpp.

References dg(), hidden, outputerr(), outputs, and weights.

Referenced by train().

◆ internalinputerr()

double NN::internalinputerr ( const std::vector< double > &  output,
const std::vector< double > &  expected,
int  which 
)
private

Definition at line 323 of file NN.cpp.

References dg(), hidden, outputerr(), outputs, and weights.

Referenced by GetInput().

◆ load() [1/4]

void NN::load ( const char *  fname)
virtual

Implements FunctionApproximator.

Definition at line 195 of file NN.cpp.

Referenced by NN().

◆ load() [2/4]

void NN::load ( const FunctionApproximator fa)
inlinevirtual

Implements FunctionApproximator.

Definition at line 17 of file NN.h.

References load().

Referenced by load().

◆ load() [3/4]

void NN::load ( const NN nn)

◆ load() [4/4]

void NN::load ( FILE *  f)
virtual

Implements FunctionApproximator.

Definition at line 208 of file NN.cpp.

References allocateMemory(), errors, freeMemory(), hiddens, inputs, outputs, VERSION, and weights.

◆ outputerr()

double NN::outputerr ( const std::vector< double > &  output,
const std::vector< double > &  expected,
int  which 
)
private

Definition at line 303 of file NN.cpp.

References dg(), kExponential, and FunctionApproximator::outputActivation.

Referenced by internalerr(), internalinputerr(), and train().

◆ Print()

void NN::Print ( )
virtual

Implements FunctionApproximator.

Definition at line 502 of file NN.cpp.

References hiddens, outputs, and weights.

◆ save() [1/2]

void NN::save ( const char *  fname)
virtual

Implements FunctionApproximator.

Definition at line 254 of file NN.cpp.

◆ save() [2/2]

void NN::save ( FILE *  f)
virtual

Implements FunctionApproximator.

Definition at line 267 of file NN.cpp.

References hiddens, inputs, outputs, VERSION, and weights.

◆ test() [1/2]

double * NN::test ( const std::vector< double > &  input)
virtual

Implements FunctionApproximator.

Definition at line 429 of file NN.cpp.

References g(), hidden, hiddens, inputs, kExponential, kStep, output, FunctionApproximator::outputActivation, outputs, and weights.

Referenced by GetInput(), and train().

◆ test() [2/2]

double * NN::test ( const std::vector< unsigned int > &  input)
virtual

◆ train() [1/2]

double NN::train ( std::vector< double > &  input,
std::vector< double > &  target 
)
virtual

◆ train() [2/2]

double NN::train ( std::vector< unsigned int > &  input,
std::vector< double > &  target 
)
virtual

◆ validSaveFile()

bool NN::validSaveFile ( char *  fname)
static

Definition at line 172 of file NN.cpp.

References VERSION.

Member Data Documentation

◆ errors

std::vector< std::vector< std::vector<double> > > NN::errors
private

Definition at line 38 of file NN.h.

Referenced by allocateMemory(), load(), and train().

◆ hidden

std::vector<double> NN::hidden
private

Definition at line 39 of file NN.h.

Referenced by allocateMemory(), internalerr(), internalinputerr(), test(), and train().

◆ hiddens

int NN::hiddens
private

Definition at line 41 of file NN.h.

Referenced by allocateMemory(), GetInput(), load(), NN(), Print(), save(), test(), and train().

◆ inputs

int NN::inputs
private

Definition at line 41 of file NN.h.

Referenced by allocateMemory(), GetInput(), getNumInputs(), load(), NN(), save(), test(), and train().

◆ output

std::vector<double> NN::output
private

Definition at line 40 of file NN.h.

Referenced by allocateMemory(), error(), GetInput(), test(), and train().

◆ outputs

int NN::outputs
private

Definition at line 41 of file NN.h.

Referenced by allocateMemory(), error(), internalerr(), internalinputerr(), load(), NN(), Print(), save(), test(), and train().

◆ updatedweights

std::vector< std::vector< std::vector<double> > > NN::updatedweights
private

Definition at line 37 of file NN.h.

Referenced by allocateMemory(), and train().

◆ weights

std::vector< std::vector< std::vector<double> > > NN::weights
private

The documentation for this class was generated from the following files: