Streaming features that support dot products among other operations.
DotFeatures support the following operations:
Definition at line 44 of file StreamingDotFeatures.h.
Public Member Functions | |
CStreamingDotFeatures () | |
CStreamingDotFeatures (CStreamingFile *file, bool is_labelled, int32_t size) | |
CStreamingDotFeatures (CDotFeatures *dot_features, float64_t *lab=NULL) | |
virtual | ~CStreamingDotFeatures () |
virtual float32_t | dot (CStreamingDotFeatures *df)=0 |
virtual float32_t | dense_dot (const float32_t *vec2, int32_t vec2_len)=0 |
virtual void | dense_dot_range (float32_t *output, float32_t *alphas, float32_t *vec, int32_t dim, float32_t b, int32_t num_vec=0) |
virtual void | add_to_dense_vec (float32_t alpha, float32_t *vec2, int32_t vec2_len, bool abs_val=false)=0 |
virtual void | expand_if_required (float32_t *&vec, int32_t &len) |
virtual void | expand_if_required (float64_t *&vec, int32_t &len) |
virtual int32_t | get_dim_feature_space () const =0 |
virtual void * | get_feature_iterator () |
virtual int32_t | get_nnz_features_for_vector () |
virtual bool | get_next_feature (int32_t &index, float32_t &value, void *iterator) |
virtual void | free_feature_iterator (void *iterator) |
Protected Attributes | |
float32_t | combined_weight |
feature weighting in combined dot features |
Constructor
Definition at line 53 of file StreamingDotFeatures.h.
CStreamingDotFeatures | ( | CStreamingFile * | file, | |
bool | is_labelled, | |||
int32_t | size | |||
) |
Constructor with input information passed.
file | CStreamingFile to take input from. | |
is_labelled | Whether examples are labelled or not. | |
size | Number of examples to be held in the parser's "ring". |
Definition at line 67 of file StreamingDotFeatures.h.
CStreamingDotFeatures | ( | CDotFeatures * | dot_features, | |
float64_t * | lab = NULL | |||
) |
Constructor taking a CDotFeatures object and optionally, labels, as args.
The derived class should implement it so that the Streaming*Features class uses the DotFeatures object as the input, getting examples one by one from the DotFeatures object (and labels, if applicable).
dot_features | CDotFeatures object | |
lab | labels (optional) |
Definition at line 86 of file StreamingDotFeatures.h.
virtual ~CStreamingDotFeatures | ( | ) | [virtual] |
Definition at line 92 of file StreamingDotFeatures.h.
virtual void add_to_dense_vec | ( | float32_t | alpha, | |
float32_t * | vec2, | |||
int32_t | vec2_len, | |||
bool | abs_val = false | |||
) | [pure virtual] |
add current vector multiplied with alpha to dense vector, 'vec'
alpha | scalar alpha | |
vec2 | real valued vector to add to | |
vec2_len | length of vector | |
abs_val | if true add the absolute value |
Implemented in CStreamingSimpleFeatures< T >, CStreamingSparseFeatures< T >, and CStreamingVwFeatures.
compute dot product between current vector and a dense vector
vec2 | real valued vector | |
vec2_len | length of vector |
Implemented in CStreamingSimpleFeatures< T >, CStreamingSparseFeatures< T >, and CStreamingVwFeatures.
virtual void dense_dot_range | ( | float32_t * | output, | |
float32_t * | alphas, | |||
float32_t * | vec, | |||
int32_t | dim, | |||
float32_t | b, | |||
int32_t | num_vec = 0 | |||
) | [virtual] |
Compute the dot product for all vectors. This function makes use of dense_dot alphas[i] * sparse[i]^T * w + b
output | result for the given vector range | |
alphas | scalars to multiply with, may be NULL | |
vec | dense vector to compute dot product with | |
dim | length of the dense vector | |
b | bias | |
num_vec | number of vectors to operate on (indices 0 to num_vec-1) |
If num_vec == 0 or left to its default value, the function attempts to return dot product for all vectors. However, the given output vector must be preallocated!
note that the result will be written to output[0...(num_vec-1)] except when num_vec = 0
Definition at line 126 of file StreamingDotFeatures.h.
virtual float32_t dot | ( | CStreamingDotFeatures * | df | ) | [pure virtual] |
compute dot product between vectors of two StreamingDotFeatures objects.
df | StreamingDotFeatures (of same kind) to compute dot product with |
Implemented in CStreamingSimpleFeatures< T >, CStreamingSparseFeatures< T >, and CStreamingVwFeatures.
virtual void expand_if_required | ( | float32_t *& | vec, | |
int32_t & | len | |||
) | [virtual] |
Expand the vector passed so that it its length is equal to the dimensionality of the features. The previous values are kept intact through realloc, and the new ones are set to zero.
vec | float32_t* vector | |
len | length of the vector |
Reimplemented in CStreamingSparseFeatures< T >, and CStreamingVwFeatures.
Definition at line 165 of file StreamingDotFeatures.h.
virtual void expand_if_required | ( | float64_t *& | vec, | |
int32_t & | len | |||
) | [virtual] |
Expand the vector passed so that it its length is equal to the dimensionality of the features. The previous values are kept intact through realloc, and the new ones are set to zero.
vec | float64_t* vector | |
len | length of the vector |
Reimplemented in CStreamingSparseFeatures< T >, and CStreamingVwFeatures.
Definition at line 184 of file StreamingDotFeatures.h.
virtual void free_feature_iterator | ( | void * | iterator | ) | [virtual] |
clean up iterator call this function with the iterator returned by get_first_feature
iterator | as returned by get_first_feature |
Definition at line 249 of file StreamingDotFeatures.h.
virtual int32_t get_dim_feature_space | ( | ) | const [pure virtual] |
obtain the dimensionality of the feature space
(not mix this up with the dimensionality of the input space, usually obtained via get_num_features())
Implemented in CStreamingSimpleFeatures< T >, CStreamingSparseFeatures< T >, and CStreamingVwFeatures.
virtual void* get_feature_iterator | ( | ) | [virtual] |
iterate over the non-zero features
call get_feature_iterator first, followed by get_next_feature and free_feature_iterator to cleanup
Definition at line 210 of file StreamingDotFeatures.h.
virtual bool get_next_feature | ( | int32_t & | index, | |
float32_t & | value, | |||
void * | iterator | |||
) | [virtual] |
iterate over the non-zero features
call this function with the iterator returned by get_first_feature and call free_feature_iterator to cleanup
index | is returned by reference (-1 when not available) | |
value | is returned by reference | |
iterator | as returned by get_first_feature |
Definition at line 238 of file StreamingDotFeatures.h.
virtual int32_t get_nnz_features_for_vector | ( | ) | [virtual] |
get number of non-zero features in vector
(in case accurate estimates are too expensive overestimating is OK)
Reimplemented in CStreamingSimpleFeatures< T >, CStreamingSparseFeatures< T >, and CStreamingVwFeatures.
Definition at line 222 of file StreamingDotFeatures.h.
float32_t combined_weight [protected] |
feature weighting in combined dot features
Reimplemented in CStreamingSimpleFeatures< T >.
Definition at line 259 of file StreamingDotFeatures.h.