diff options
author | ariel faigon <github.2009@yendor.com> | 2014-01-04 03:53:09 +0400 |
---|---|---|
committer | ariel faigon <github.2009@yendor.com> | 2014-01-04 03:53:09 +0400 |
commit | d90f649b627e89fd8c092ae96eba9e53c7194479 (patch) | |
tree | 4fd98e694bf67eb1411f63e93687223031b3dada /vowpalwabbit/vw.h | |
parent | f5648703929713d9f251d893823f0b75105d5eac (diff) |
Add --progress <arg> support
Diffstat (limited to 'vowpalwabbit/vw.h')
-rw-r--r-- | vowpalwabbit/vw.h | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/vowpalwabbit/vw.h b/vowpalwabbit/vw.h index 56d1ae1d..66e5acad 100644 --- a/vowpalwabbit/vw.h +++ b/vowpalwabbit/vw.h @@ -13,7 +13,7 @@ license as described in the file LICENSE. namespace VW { -/* Caveats: +/* Caveats: (1) Some commandline parameters do not make sense as a library. (2) The code is not yet reentrant. */ @@ -29,13 +29,14 @@ namespace VW { void finish(vw& all); void start_parser(vw& all, bool do_init = true); - void end_parser(vw& all); - + void end_parser(vw& all); + typedef pair< unsigned char, vector<feature> > feature_space; //just a helper definition. struct primitive_feature_space { //just a helper definition. - unsigned char name; - feature* fs; - size_t len; }; + unsigned char name; + feature* fs; + size_t len; + }; //The next commands deal with creating examples. Caution: VW does not all allow creation of many examples at once by default. You can adjust the exact number by tweaking ring_size. @@ -43,7 +44,7 @@ namespace VW { */ example* read_example(vw& all, char* example_line); - //The more complex way to create an example. + //The more complex way to create an example. //after you create and fill feature_spaces, get an example with everything filled in. example* import_example(vw& all, primitive_feature_space* features, size_t len); @@ -53,21 +54,21 @@ namespace VW { example* get_example(parser* pf); label_data* get_label(example*ec); - void add_constant_feature(vw& all, example*ec); - void add_label(example* ec, float label, float weight = 1, float base = 0); + void add_constant_feature(vw& all, example*ec); + void add_label(example* ec, float label, float weight = 1, float base = 0); + //notify VW that you are done with the example. void finish_example(vw& all, example* ec); void copy_example_data(bool audit, example*&, example*, size_t, void(*copy_example)(void*&,void*)); - // after export_example, must call releaseFeatureSpace to free native memory + // after export_example, must call releaseFeatureSpace to free native memory primitive_feature_space* export_example(vw& all, example* e, size_t& len); void releaseFeatureSpace(primitive_feature_space* features, size_t len); - - // inlines + // inlines - //First create the hash of a namespace. + //First create the hash of a namespace. inline uint32_t hash_space(vw& all, string s) { substring ss; @@ -92,18 +93,25 @@ namespace VW { return (uint32_t)(all.p->hasher(ss,u) & all.parse_mask); } - inline float get_weight(vw& all, uint32_t index, uint32_t offset) + inline float get_weight(vw& all, uint32_t index, uint32_t offset) { return all.reg.weight_vector[((index * all.reg.stride + offset) & all.reg.weight_mask)];} - inline void set_weight(vw& all, uint32_t index, uint32_t offset, float value) + inline void set_weight(vw& all, uint32_t index, uint32_t offset, float value) { all.reg.weight_vector[((index * all.reg.stride + offset) & all.reg.weight_mask)] = value;} - inline uint32_t num_weights(vw& all) + inline uint32_t num_weights(vw& all) { return (uint32_t)all.length();} - inline uint32_t get_stride(vw& all) + inline uint32_t get_stride(vw& all) { return (uint32_t)all.reg.stride;} + inline void update_dump_interval(vw& all) { + if (all.progress_add) { + all.sd->dump_interval += all.progress_arg; + } else { + all.sd->dump_interval *= all.progress_arg; + } + } } #endif |