perceptron.cpp File Reference

#include <assert.h>
#include <cmath>
#include <numeric>
#include "random.h"
#include "stump.h"
#include "perceptron.h"

Include dependency graph for perceptron.cpp:

Go to the source code of this file.

Namespaces

namespace  lemga

Defines

#define PERCEPTRON_FIXED_BIAS   0
#define STUMP_DOUBLE_DIRECTIONS   0
#define DOTPROD(x, y)   std::inner_product(x.begin(), x.end(), y.begin(), .0)
#define DOTPROD_NB(x, y)   std::inner_product(x.begin(),x.end()-1,y.begin(),.0)
#define RAND_IDX()   (resample? randcdf(randu(),cdf) : UINT(randu()*n_samples))
#define SAMPWGT(i)   (resample? 1 : (*ptw)[i]*n_samples)
#define GET_XYO(i)
#define CYCLE(r)   (((r)+dim-1) % udim)
#define UPDATE_WGT(d)   update_wgt(wgt, d, X, Y)
#define INPUT_SUM(w, x)   std::inner_product(x.begin(), x.end(), w.begin(), w.back())

Typedefs

typedef std::vector< REALRVEC
typedef std::vector< RVECRMAT

Functions

 REGISTER_CREATOR (lemga::Perceptron)
RVEC randvec (UINT n)
RVEC coorvec (UINT n, UINT c)
void normalize (RVEC &v, REAL thr=0)
RMAT randrot (UINT n, bool bias_row=false, bool conjugate=true)
bool Cholesky_decomp (RMAT &A, RVEC &p)
void Cholesky_linsol (const RMAT &A, const RVEC &p, const RVEC &b, RVEC &x)
bool lemga::ldivide (RMAT &A, const RVEC &b, RVEC &x)
void lemga::update_wgt (RVEC &wgt, const RVEC &dir, const RMAT &X, const RVEC &y)
void lemga::dset_extract (const pDataSet &ptd, RMAT &X, RVEC &y)
void lemga::dset_mult_wgt (const pDataWgt &ptw, RVEC &y)
UINT lemga::randcdf (REAL r, const RVEC &cdf)


Detailed Description

Id
perceptron.cpp 2542 2006-01-10 07:24:14Z ling

Definition in file perceptron.cpp.


Define Documentation

#define CYCLE  )     (((r)+dim-1) % udim)
 

#define DOTPROD x,
 )     std::inner_product(x.begin(), x.end(), y.begin(), .0)
 

Definition at line 27 of file perceptron.cpp.

#define DOTPROD_NB x,
 )     std::inner_product(x.begin(),x.end()-1,y.begin(),.0)
 

Definition at line 29 of file perceptron.cpp.

Referenced by Perceptron::w_norm().

#define GET_XYO  ) 
 

Value:

const Input& x = X[i]; \
    const REAL y = Y[i];   \
    const REAL o = DOTPROD(wgt,x)

Referenced by Perceptron::train().

#define INPUT_SUM w,
 )     std::inner_product(x.begin(), x.end(), w.begin(), w.back())
 

Definition at line 676 of file perceptron.cpp.

Referenced by Perceptron::margin_of(), and Perceptron::operator()().

#define PERCEPTRON_FIXED_BIAS   0
 

Definition at line 11 of file perceptron.cpp.

Referenced by Perceptron::initialize(), and Perceptron::train().

 
#define RAND_IDX  )     (resample? randcdf(randu(),cdf) : UINT(randu()*n_samples))
 

Referenced by Perceptron::train().

#define SAMPWGT  )     (resample? 1 : (*ptw)[i]*n_samples)
 

Referenced by Perceptron::train().

#define STUMP_DOUBLE_DIRECTIONS   0
 

Definition at line 13 of file perceptron.cpp.

#define UPDATE_WGT  )     update_wgt(wgt, d, X, Y)
 


Typedef Documentation

typedef std::vector<RVEC> RMAT
 

Definition at line 25 of file perceptron.cpp.

typedef std::vector<REAL> RVEC
 

Definition at line 24 of file perceptron.cpp.


Function Documentation

bool Cholesky_decomp RMAT A,
RVEC p
 

Definition at line 79 of file perceptron.cpp.

Referenced by lemga::ldivide().

void Cholesky_linsol const RMAT A,
const RVEC p,
const RVEC b,
RVEC x
 

Definition at line 99 of file perceptron.cpp.

Referenced by lemga::ldivide().

RVEC coorvec UINT  n,
UINT  c
[inline]
 

Definition at line 38 of file perceptron.cpp.

Referenced by randrot().

void normalize RVEC v,
REAL  thr = 0
[inline]
 

Definition at line 44 of file perceptron.cpp.

References DOTPROD.

RMAT randrot UINT  n,
bool  bias_row = false,
bool  conjugate = true
 

Definition at line 53 of file perceptron.cpp.

References coorvec(), DOTPROD, and randvec().

RVEC randvec UINT  n  )  [inline]
 

Definition at line 31 of file perceptron.cpp.

References randu.

Referenced by randrot().

REGISTER_CREATOR lemga::Perceptron   ) 
 


Generated on Mon Jan 9 23:44:02 2006 for LEMGA by  doxygen 1.4.6