MCPcopy Create free account
hub / github.com/davisking/dlib / get_features

Method get_features

dlib/svm/sequence_segmenter.h:209–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207
208 template <typename feature_setter, typename EXP>
209 void get_features (
210 feature_setter& set_feature,
211 const sequence_type& x,
212 const matrix_exp<EXP>& y,
213 unsigned long position
214 ) const
215 {
216 unsigned long offset = 0;
217
218 const int window_size = fe.window_size();
219
220 const int base_dims = fe.num_features();
221 for (int i = 0; i < window_size; ++i)
222 {
223 const long pos = i-window_size/2 + static_cast<long>(position);
224 if (0 <= pos && pos < (long)x.size())
225 {
226 const unsigned long off1 = y(0)*base_dims;
227 dot_functor<feature_setter> fs1(set_feature, offset+off1);
228 fe.get_features(fs1, x, pos);
229
230 if (ss_feature_extractor::use_high_order_features && y.size() > 1)
231 {
232 const unsigned long off2 = num_labels()*base_dims + (y(0)*num_labels()+y(1))*base_dims;
233 dot_functor<feature_setter> fs2(set_feature, offset+off2);
234 fe.get_features(fs2, x, pos);
235 }
236 }
237
238 if (ss_feature_extractor::use_high_order_features)
239 offset += num_labels()*base_dims + num_labels()*num_labels()*base_dims;
240 else
241 offset += num_labels()*base_dims;
242 }
243
244 // Pull out an indicator feature for the type of transition between the
245 // previous label and the current label.
246 if (y.size() > 1)
247 set_feature(offset + y(1)*num_labels() + y(0));
248
249 offset += num_labels()*num_labels();
250 // pull out an indicator feature for the current label. This is the per
251 // label bias.
252 set_feature(offset + y(0));
253 }
254 };
255
256 } // end namespace impl_ss

Callers 5

predict_assignmentsMethod · 0.45
dotFunction · 0.45
separation_oracleMethod · 0.45
get_feature_vectorFunction · 0.45

Calls 4

yFunction · 0.85
window_sizeMethod · 0.45
num_featuresMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected