#include <perceptron.h>
Inheritance diagram for Perceptron:
Public Types | |
typedef std::vector< REAL > | WEIGHT |
enum | TRAIN_METHOD { PERCEPTRON, ADALINE, POCKET, POCKET_RATCHET, AVE_PERCEPTRON, ROMMA, ROMMA_AGG, SGD_HINGE, SGD_MLSE, RCD, RCD_BIAS, RCD_GRAD, AVE_PERCEPTRON_RAND, ROMMA_RAND, ROMMA_AGG_RAND, COORDINATE_DESCENT, FIXED_RCD, FIXED_RCD_CONJ, FIXED_RCD_BIAS, FIXED_RCD_CONJ_BIAS, RCD_CONJ, RCD_CONJ_BIAS, RCD_GRAD_BATCH, RCD_GRAD_RAND, RCD_GRAD_BATCH_RAND, RCD_MIXED, RCD_GRAD_MIXED, RCD_GRAD_MIXED_INITRAND, RCD_GRAD_MIXED_BATCH, RCD_GRAD_MIXED_BATCH_INITRAND, RAND_COOR_DESCENT = RCD, RAND_COOR_DESCENT_BIAS = RCD_BIAS, RAND_CONJ_DESCENT = RCD_CONJ, RAND_CONJ_DESCENT_BIAS = RCD_CONJ_BIAS, GRADIENT_COOR_DESCENT_ONLINE = RCD_GRAD } |
Public Member Functions | |
Perceptron (UINT n_in=0) | |
Perceptron (const SVM &) | |
Perceptron (std::istream &is) | |
virtual const id_t & | id () const |
virtual Perceptron * | create () const |
Create a new object using the default constructor. | |
virtual Perceptron * | clone () const |
Create a new object by replicating itself. | |
WEIGHT | weight () const |
void | set_weight (const WEIGHT &) |
void | start_with_fld (bool b=true) |
void | set_fixed_bias (bool b=false) |
void | use_resample (bool s=true) |
void | set_train_method (TRAIN_METHOD m) |
void | set_parameter (REAL lr, REAL mincst, UINT maxrun) |
virtual bool | support_weighted_data () const |
Whether the learning model/algorithm supports unequally weighted data. | |
virtual void | initialize () |
WEIGHT | fld () const |
virtual void | train () |
Train with preset data set and sample weight. | |
virtual Output | operator() (const Input &) const |
virtual REAL | margin_norm () const |
The normalization term for margins. | |
virtual REAL | margin_of (const Input &, const Output &) const |
Report the (unnormalized) margin of an example (x, y). | |
REAL | w_norm () const |
Protected Member Functions | |
virtual bool | serialize (std::ostream &, ver_list &) const |
virtual bool | unserialize (std::istream &, ver_list &, const id_t &=NIL_ID) |
virtual void | log_error (UINT, REAL=-1) const |
Protected Attributes | |
WEIGHT | wgt |
wgt.back() is the bias | |
bool | resample |
reweighting or resampling | |
TRAIN_METHOD | train_method |
REAL | learn_rate |
REAL | min_cst |
UINT | max_run |
bool | with_fld |
start training with FLD? | |
bool | fixed_bias |
using a fixed bias? |
We use the convention that is the negative threshold, or equivalently, letting
. When presented with input
, the perceptron outputs
where is usually the sign function,
The learning algorithm updates the weight according to
where is the desired output. If
is the sign, the learning rate
can be omitted since it just scales
.
Definition at line 35 of file perceptron.h.
|
Definition at line 37 of file perceptron.h. |
|
Definition at line 38 of file perceptron.h. |
|
Definition at line 144 of file perceptron.cpp. Referenced by Perceptron::clone(), and Perceptron::create(). |
|
Definition at line 151 of file perceptron.cpp. References LearnModel::_n_in, Object::id(), SVM::kernel(), SVM::n_support_vectors(), SVM::support_vector(), SVM::support_vector_coef(), and Perceptron::wgt. |
|
Definition at line 93 of file perceptron.h. |
|
Create a new object by replicating itself.
return new Derived(*this);
Implements LearnModel. Definition at line 97 of file perceptron.h. References Perceptron::Perceptron(). |
|
Create a new object using the default constructor. The code for a derived class Derived is always return new Derived(); Implements LearnModel. Definition at line 96 of file perceptron.h. References Perceptron::Perceptron(). |
|
Definition at line 200 of file perceptron.cpp. References LearnModel::_n_in, LearnModel::n_samples, LearnModel::ptd, and LearnModel::ptw. Referenced by Perceptron::train(). |
|
Implements Object. |
|
Reimplemented from LearnModel. Definition at line 192 of file perceptron.cpp. References LearnModel::_n_in, Perceptron::fixed_bias, LearnModel::ptd, randu, LearnModel::set_dimensions(), and Perceptron::wgt. |
|
Definition at line 637 of file perceptron.cpp. References LearnModel::logf, and LearnModel::train_c_error(). Referenced by Perceptron::train(). |
|
The normalization term for margins. The margin concept can be normalized or unnormalized. For example, for a perceptron model, the unnormalized margin would be the wegithed sum of the input features, and the normalized margin would be the distance to the hyperplane, and the normalization term is the norm of the hyperplane weight. Since the normalization term is usually a constant, it would be more efficient if it is precomputed instead of being calculated every time when a margin is asked for. The best way is to use a cache. Here I use a easier way: let the users decide when to compute the normalization term. Reimplemented from LearnModel. Definition at line 120 of file perceptron.h. References Perceptron::w_norm(). |
|
Report the (unnormalized) margin of an example (x, y).
Reimplemented from LearnModel. Definition at line 627 of file perceptron.cpp. References INFINITESIMAL, INPUT_SUM, and Perceptron::wgt. |
|
Implements LearnModel. Definition at line 621 of file perceptron.cpp. References INPUT_SUM, LearnModel::n_input(), and Perceptron::wgt. |
|
Reimplemented from LearnModel. Definition at line 169 of file perceptron.cpp. References LearnModel::_n_in, SERIALIZE_PARENT, and Perceptron::wgt. |
|
Definition at line 103 of file perceptron.h. References Perceptron::fixed_bias. |
|
Definition at line 111 of file perceptron.h. References Perceptron::learn_rate, Perceptron::max_run, and Perceptron::min_cst. |
|
Definition at line 105 of file perceptron.h. References Perceptron::train_method. |
|
Definition at line 186 of file perceptron.cpp. References LearnModel::set_dimensions(), and Perceptron::wgt. |
|
Definition at line 102 of file perceptron.h. References Perceptron::with_fld. |
|
Whether the learning model/algorithm supports unequally weighted data.
Reimplemented from LearnModel. Definition at line 114 of file perceptron.h. |
|
Train with preset data set and sample weight.
Implements LearnModel. Definition at line 281 of file perceptron.cpp. References Perceptron::ADALINE, lemga::dset_extract(), EPSILON, Perceptron::fixed_bias, Perceptron::fld(), GET_XYO, Perceptron::learn_rate, Perceptron::log_error(), Perceptron::max_run, Perceptron::PERCEPTRON, LearnModel::ptd, LearnModel::ptw, RAND_IDX, Perceptron::resample, SAMPWGT, LearnModel::set_dimensions(), Perceptron::train_method, Perceptron::wgt, and Perceptron::with_fld. |
|
Reimplemented from LearnModel. Definition at line 176 of file perceptron.cpp. References LearnModel::_n_in, Object::NIL_ID, UNSERIALIZE_PARENT, and Perceptron::wgt. |
|
Definition at line 104 of file perceptron.h. References Perceptron::resample. |
|
Definition at line 632 of file perceptron.cpp. References DOTPROD_NB, and Perceptron::wgt. Referenced by Perceptron::margin_norm(). |
|
Definition at line 99 of file perceptron.h. References Perceptron::wgt. |
|
using a fixed bias?
Definition at line 88 of file perceptron.h. Referenced by Perceptron::initialize(), Perceptron::set_fixed_bias(), and Perceptron::train(). |
|
Definition at line 85 of file perceptron.h. Referenced by Perceptron::set_parameter(), and Perceptron::train(). |
|
Definition at line 86 of file perceptron.h. Referenced by Perceptron::set_parameter(), and Perceptron::train(). |
|
Definition at line 85 of file perceptron.h. Referenced by Perceptron::set_parameter(). |
|
reweighting or resampling
Definition at line 83 of file perceptron.h. Referenced by Perceptron::train(), and Perceptron::use_resample(). |
|
Definition at line 84 of file perceptron.h. Referenced by Perceptron::set_train_method(), and Perceptron::train(). |
|
wgt.back() is the bias
Definition at line 81 of file perceptron.h. Referenced by Perceptron::initialize(), Perceptron::margin_of(), Perceptron::operator()(), Perceptron::Perceptron(), Perceptron::serialize(), Perceptron::set_weight(), Perceptron::train(), Perceptron::unserialize(), Perceptron::w_norm(), and Perceptron::weight(). |
|
start training with FLD?
Definition at line 87 of file perceptron.h. Referenced by Perceptron::start_with_fld(), and Perceptron::train(). |