perceptron.cpp File Reference

#include <assert.h>
#include <cmath>
#include <numeric>
#include "random.h"
#include "utility.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 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 INIT_RCD()
#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)
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 2891 2006-11-08 03:17:31Z 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 INIT_RCD  ) 
 

Value:

{                      \
    dset_mult_wgt(ptw, Y);                \
}

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

Definition at line 618 of file perceptron.cpp.

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

 
#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 12 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

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 Wed Nov 8 08:16:07 2006 for LEMGA by  doxygen 1.4.6