PLearn 0.1
|
Public Member Functions | |
thread_wawr (int thread_id_, int n_threads_, const TVec< RealFunc > &functions_, real &wsum_, Vec &E_x_, Vec &E_xx_, real &E_y_, real &E_yy_, Vec &E_xy_, const Vec &Y_, boost::mutex &ts_mx_, const VMat &train_set_, boost::mutex &pb_mx_, PP< ProgressBar > pb_, int thread_subtrain_length_) | |
void | operator() () |
Public Attributes | |
int | thread_id |
int | n_threads |
const TVec< RealFunc > & | functions |
real & | wsum |
Vec & | E_x |
Vec & | E_xx |
real & | E_y |
real & | E_yy |
Vec & | E_xy |
const Vec & | Y |
boost::mutex & | ts_mx |
const VMat & | train_set |
boost::mutex & | pb_mx |
PP< ProgressBar > | pb |
int | thread_subtrain_length |
Definition at line 717 of file BasisSelectionRegressor.cc.
PLearn::BasisSelectionRegressor::thread_wawr::thread_wawr | ( | int | thread_id_, |
int | n_threads_, | ||
const TVec< RealFunc > & | functions_, | ||
real & | wsum_, | ||
Vec & | E_x_, | ||
Vec & | E_xx_, | ||
real & | E_y_, | ||
real & | E_yy_, | ||
Vec & | E_xy_, | ||
const Vec & | Y_, | ||
boost::mutex & | ts_mx_, | ||
const VMat & | train_set_, | ||
boost::mutex & | pb_mx_, | ||
PP< ProgressBar > | pb_, | ||
int | thread_subtrain_length_ | ||
) | [inline] |
Definition at line 734 of file BasisSelectionRegressor.cc.
void PLearn::BasisSelectionRegressor::thread_wawr::operator() | ( | ) | [inline] |
Definition at line 761 of file BasisSelectionRegressor.cc.
References PLearn::TVec< T >::append(), PLearn::TMat< T >::appendRow(), E_x, E_xx, E_xy, E_y, E_yy, PLearn::evaluate_functions(), PLearn::TVec< T >::fill(), functions, PLearn::VMat::getExample(), i, PLearn::BasisSelectionRegressor::input, j, PLearn::VMat::length(), PLearn::TVec< T >::length(), PLearn::min(), n_threads, pb, pb_mx, PLearn::TMat< T >::resize(), PLearn::TVec< T >::resize(), PLearn::BasisSelectionRegressor::targ, thread_id, thread_subtrain_length, train_set, ts_mx, w, wsum, and x.
{ Vec input, targ; real w; Vec candidate_features; int n_candidates = functions.length(); int train_len = train_set->length(); E_x.resize(n_candidates); E_x.fill(0.); E_xx.resize(n_candidates); E_xx.fill(0.); E_y = 0.; E_yy = 0.; E_xy.resize(n_candidates); E_xy.fill(0.); wsum = 0.; // Used when thread_subtrain_length > 1 Mat all_inputs; Vec all_w; int input_size = train_set->inputsize(); if (thread_subtrain_length > 1) { // pre-allocate memory all_inputs.resize(thread_subtrain_length, input_size); all_w.resize(thread_subtrain_length); } for(int i=thread_id; i<train_len; i+= n_threads) { if (thread_subtrain_length > 1) { int j = (i-thread_id)/n_threads; int j_mod = j % thread_subtrain_length; if (j_mod == 0) // on doit faire le plein de donnees { all_inputs.resize(0, input_size); all_w.resize(0); boost::mutex::scoped_lock lock(ts_mx); int max_train = min(train_len, i + thread_subtrain_length*n_threads); for (int ii=i; ii<max_train; ii+= n_threads) { train_set->getExample(ii, input, targ, w); all_inputs.appendRow(input); all_w.append(w); } } input = all_inputs(j_mod); w = all_w[j_mod]; } else { boost::mutex::scoped_lock lock(ts_mx); train_set->getExample(i, input, targ, w); } evaluate_functions(functions, input, candidate_features); wsum += w; real y = Y[i]; real wy = w*y; E_y += wy; E_yy += wy*y; for(int j=0; j<n_candidates; j++) { real x = candidate_features[j]; real wx = w*x; E_x[j] += wx; E_xx[j] += wx*x; E_xy[j] += wx*y; } if(pb) { boost::mutex::scoped_lock lock(pb_mx); if(pb->currentpos < static_cast<unsigned int>(i)) pb->update(i); } } }
Definition at line 722 of file BasisSelectionRegressor.cc.
Referenced by operator()().
Definition at line 723 of file BasisSelectionRegressor.cc.
Referenced by operator()().
Definition at line 726 of file BasisSelectionRegressor.cc.
Referenced by operator()().
Definition at line 724 of file BasisSelectionRegressor.cc.
Referenced by operator()().
Definition at line 725 of file BasisSelectionRegressor.cc.
Referenced by operator()().
Definition at line 720 of file BasisSelectionRegressor.cc.
Referenced by operator()().
Definition at line 719 of file BasisSelectionRegressor.cc.
Referenced by operator()().
Definition at line 731 of file BasisSelectionRegressor.cc.
Referenced by operator()().
boost::mutex& PLearn::BasisSelectionRegressor::thread_wawr::pb_mx |
Definition at line 730 of file BasisSelectionRegressor.cc.
Referenced by operator()().
Definition at line 719 of file BasisSelectionRegressor.cc.
Referenced by operator()().
Definition at line 732 of file BasisSelectionRegressor.cc.
Referenced by operator()().
Definition at line 729 of file BasisSelectionRegressor.cc.
Referenced by operator()().
boost::mutex& PLearn::BasisSelectionRegressor::thread_wawr::ts_mx |
Definition at line 728 of file BasisSelectionRegressor.cc.
Referenced by operator()().
Definition at line 721 of file BasisSelectionRegressor.cc.
Referenced by operator()().
Definition at line 727 of file BasisSelectionRegressor.cc.