HOG2
Perceptron.h
Go to the documentation of this file.
1 /*
2  * perceptron.h
3  * games
4  *
5  * Created by Nathan Sturtevant on 3/2/05.
6  * Copyright 2005 __MyCompanyName__. All rights reserved.
7  *
8  */
9 
10 #ifndef PERCEPTRON_H
11 #define PERCEPTRON_H
12 #include "FunctionApproximator.h"
13 
15 public:
16  perceptron(int inputs, int outputs, double learnrate);
18  perceptron(char *);
20  ~perceptron();
21 
22  void save(const char *);
23  void save(FILE *);
24  void load(const char *);
25  void load(FILE *);
26  void load(const FunctionApproximator *fa) { load((perceptron*)fa); }
27  void load(const perceptron *);
28  static bool validSaveFile(char *fname);
29 
30  double train(std::vector<double> &input, std::vector<double> &output2);
31  double *test(const std::vector<double> &input);
32  double train(std::vector<unsigned int> &input, std::vector<double> &output2);
33  double *test(const std::vector<unsigned int> &input);
34 
35  void Print();
36 
37  int getNumInputs() { return inputs+1; }
38  double getInputWeight(int inp, int outp=0) { return weight[outp][inp]; }
39 private:
40  void allocateMemory();
41  void freeMemory();
42 
43  double g(double a);
44  double dg(double a);
45  double outputerr(const std::vector<double> &output, const std::vector<double> &expected, int which);
46 
47  double error(double* output);
48  std::vector<std::vector<double> > weight;
49  std::vector<double> output;
50  //double** weight;
51  //double* output;
53 };
54 
55 #endif
perceptron::allocateMemory
void allocateMemory()
Definition: Perceptron.cpp:66
perceptron::train
double train(std::vector< double > &input, std::vector< double > &output2)
Definition: Perceptron.cpp:237
perceptron::getInputWeight
double getInputWeight(int inp, int outp=0)
Definition: Perceptron.h:38
perceptron::getNumInputs
int getNumInputs()
Definition: Perceptron.h:37
FunctionApproximator.h
perceptron::output
std::vector< double > output
Definition: Perceptron.h:49
perceptron::save
void save(const char *)
Definition: Perceptron.cpp:191
perceptron::test
double * test(const std::vector< double > &input)
Definition: Perceptron.cpp:272
perceptron::g
double g(double a)
FunctionApproximator
Definition: FunctionApproximator.h:25
perceptron::~perceptron
~perceptron()
Definition: Perceptron.cpp:61
perceptron::perceptron
perceptron(int inputs, int outputs, double learnrate)
Definition: Perceptron.cpp:18
perceptron::dg
double dg(double a)
perceptron::load
void load(const char *)
Definition: Perceptron.cpp:95
perceptron
Definition: Perceptron.h:14
perceptron::outputs
int outputs
Definition: Perceptron.h:52
perceptron::load
void load(const FunctionApproximator *fa)
Definition: Perceptron.h:26
perceptron::freeMemory
void freeMemory()
Definition: Perceptron.cpp:82
perceptron::weight
std::vector< std::vector< double > > weight
Definition: Perceptron.h:48
perceptron::outputerr
double outputerr(const std::vector< double > &output, const std::vector< double > &expected, int which)
Definition: Perceptron.cpp:230
perceptron::Print
void Print()
Definition: Perceptron.cpp:306
perceptron::inputs
int inputs
Definition: Perceptron.h:52
perceptron::validSaveFile
static bool validSaveFile(char *fname)
Definition: Perceptron.cpp:168
perceptron::error
double error(double *output)