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

#include <Perceptron.h>

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

Public Member Functions

 perceptron (int inputs, int outputs, double learnrate)
 
 perceptron (perceptron *)
 
 perceptron (char *)
 
 perceptron (FunctionApproximator *)
 
 ~perceptron ()
 
void save (const char *)
 
void save (FILE *)
 
void load (const char *)
 
void load (FILE *)
 
void load (const FunctionApproximator *fa)
 
void load (const perceptron *)
 
double train (std::vector< double > &input, std::vector< double > &output2)
 
double * test (const std::vector< double > &input)
 
double train (std::vector< unsigned int > &input, std::vector< double > &output2)
 
double * test (const std::vector< unsigned int > &input)
 
void Print ()
 
int getNumInputs ()
 
double getInputWeight (int inp, int outp=0)
 
- Public Member Functions inherited from FunctionApproximator
 FunctionApproximator ()
 
virtual ~FunctionApproximator ()
 
virtual double GetInput (std::vector< double > &input, const std::vector< double > &target)=0
 
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 ()
 
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 error (double *output)
 

Private Attributes

std::vector< std::vector< double > > weight
 
std::vector< double > output
 
int inputs
 
int outputs
 

Additional Inherited Members

- Protected Attributes inherited from FunctionApproximator
double rate
 
tActivation outputActivation
 

Detailed Description

Definition at line 14 of file Perceptron.h.

Constructor & Destructor Documentation

◆ perceptron() [1/4]

perceptron::perceptron ( int  inputs,
int  outputs,
double  learnrate 
)

◆ perceptron() [2/4]

perceptron::perceptron ( perceptron perp)

◆ perceptron() [3/4]

perceptron::perceptron ( char *  f)

Definition at line 40 of file Perceptron.cpp.

References inputs, load(), outputs, and weight.

◆ perceptron() [4/4]

perceptron::perceptron ( FunctionApproximator fa)

◆ ~perceptron()

perceptron::~perceptron ( )

Definition at line 61 of file Perceptron.cpp.

References freeMemory().

Member Function Documentation

◆ allocateMemory()

void perceptron::allocateMemory ( )
private

Definition at line 66 of file Perceptron.cpp.

References inputs, output, outputs, and weight.

Referenced by load(), and perceptron().

◆ dg()

double perceptron::dg ( double  a)
private

◆ error()

double perceptron::error ( double *  output)
private

◆ freeMemory()

void perceptron::freeMemory ( )
private

Definition at line 82 of file Perceptron.cpp.

References weight.

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

◆ g()

double perceptron::g ( double  a)
private

◆ getInputWeight()

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

Reimplemented from FunctionApproximator.

Definition at line 38 of file Perceptron.h.

References weight.

◆ getNumInputs()

int perceptron::getNumInputs ( )
inlinevirtual

Reimplemented from FunctionApproximator.

Definition at line 37 of file Perceptron.h.

References inputs.

◆ load() [1/4]

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

Implements FunctionApproximator.

Definition at line 95 of file Perceptron.cpp.

Referenced by perceptron().

◆ load() [2/4]

void perceptron::load ( const FunctionApproximator fa)
inlinevirtual

Implements FunctionApproximator.

Definition at line 26 of file Perceptron.h.

References load().

Referenced by load().

◆ load() [3/4]

void perceptron::load ( const perceptron p)

◆ load() [4/4]

void perceptron::load ( FILE *  f)
virtual

Implements FunctionApproximator.

Definition at line 115 of file Perceptron.cpp.

References allocateMemory(), freeMemory(), inputs, outputs, VERSION, and weight.

◆ outputerr()

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

Definition at line 230 of file Perceptron.cpp.

Referenced by train().

◆ Print()

void perceptron::Print ( )
virtual

Implements FunctionApproximator.

Definition at line 306 of file Perceptron.cpp.

References inputs, outputs, and weight.

◆ save() [1/2]

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

Implements FunctionApproximator.

Definition at line 191 of file Perceptron.cpp.

◆ save() [2/2]

void perceptron::save ( FILE *  f)
virtual

Implements FunctionApproximator.

Definition at line 204 of file Perceptron.cpp.

References inputs, outputs, VERSION, and weight.

◆ test() [1/2]

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

Implements FunctionApproximator.

Definition at line 272 of file Perceptron.cpp.

References inputs, kStep, output, FunctionApproximator::outputActivation, outputs, and weight.

Referenced by train().

◆ test() [2/2]

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

Implements FunctionApproximator.

Definition at line 293 of file Perceptron.cpp.

References inputs, output, outputs, and weight.

◆ train() [1/2]

double perceptron::train ( std::vector< double > &  input,
std::vector< double > &  output2 
)
virtual

Implements FunctionApproximator.

Definition at line 237 of file Perceptron.cpp.

References inputs, output, outputerr(), outputs, FunctionApproximator::rate, test(), and weight.

◆ train() [2/2]

double perceptron::train ( std::vector< unsigned int > &  input,
std::vector< double > &  output2 
)
virtual

Implements FunctionApproximator.

Definition at line 254 of file Perceptron.cpp.

References inputs, output, outputerr(), outputs, FunctionApproximator::rate, test(), and weight.

◆ validSaveFile()

bool perceptron::validSaveFile ( char *  fname)
static

Definition at line 168 of file Perceptron.cpp.

References VERSION.

Member Data Documentation

◆ inputs

int perceptron::inputs
private

Definition at line 52 of file Perceptron.h.

Referenced by allocateMemory(), getNumInputs(), load(), perceptron(), Print(), save(), test(), and train().

◆ output

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

Definition at line 49 of file Perceptron.h.

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

◆ outputs

int perceptron::outputs
private

Definition at line 52 of file Perceptron.h.

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

◆ weight

std::vector<std::vector<double> > perceptron::weight
private

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