Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Proper env min/max label updating for cached input in VW.
  • Loading branch information
frx committed Aug 24, 2011
1 parent 0c3aaf8 commit dcfb2d6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/shogun/classifier/vw/cache/VwCacheReader.h
Expand Up @@ -91,6 +91,37 @@ class CVwCacheReader: public CSGObject
*/
virtual CVwEnvironment* get_env();

/**
* Update min and max labels seen in the environment
*
* @param label current label based on which to update
*/
virtual void set_mm(float64_t label)
{
env->min_label = CMath::min(env->min_label, label);
if (label != FLT_MAX)
env->max_label = CMath::max(env->max_label, label);
}

/**
* A dummy function performing no operation in case training
* is not to be performed.
*
* @param label label
*/
virtual void noop_mm(float64_t label) { }

/**
* Function which is actually called to update min and max labels
* Should be set to one of the functions implemented for this.
*
* @param label label based on which to update
*/
virtual void set_minmax(float64_t label)
{
set_mm(label);
}

/**
* Function to read one example from the cache
*
Expand Down
2 changes: 2 additions & 0 deletions src/shogun/classifier/vw/cache/VwNativeCacheReader.cpp
Expand Up @@ -97,6 +97,8 @@ char* CVwNativeCacheReader::bufread_label(VwLabel* const ld, char* c)
{
ld->label = *(float32_t*)c;
c += sizeof(ld->label);
set_minmax(ld->label);

ld->weight = *(float32_t*)c;
c += sizeof(ld->weight);
ld->initial = *(float32_t*)c;
Expand Down

0 comments on commit dcfb2d6

Please sign in to comment.