SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
CDotFeatures Class Reference

Detailed Description

Features that support dot products among other operations.

DotFeatures support the following operations:

\[r = {\bf x} \cdot {\bf x'}\]

\[r = {\bf x} \cdot {\bf z}\]

\[ {\bf z'} = \alpha {\bf x} + {\bf z} \]

Definition at line 41 of file DotFeatures.h.

Inheritance diagram for CDotFeatures:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CDotFeatures (int32_t size=0)
 CDotFeatures (const CDotFeatures &orig)
 CDotFeatures (CFile *loader)
virtual ~CDotFeatures ()
virtual int32_t get_dim_feature_space () const =0
virtual float64_t dot (int32_t vec_idx1, CDotFeatures *df, int32_t vec_idx2)=0
virtual float64_t dense_dot (int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)=0
virtual void add_to_dense_vec (float64_t alpha, int32_t vec_idx1, float64_t *vec2, int32_t vec2_len, bool abs_val=false)=0
virtual void dense_dot_range (float64_t *output, int32_t start, int32_t stop, float64_t *alphas, float64_t *vec, int32_t dim, float64_t b)
virtual void dense_dot_range_subset (int32_t *sub_index, int32_t num, float64_t *output, float64_t *alphas, float64_t *vec, int32_t dim, float64_t b)
virtual int32_t get_nnz_features_for_vector (int32_t num)=0
float64_t get_combined_feature_weight ()
void set_combined_feature_weight (float64_t nw)
SGMatrix< float64_tget_computed_dot_feature_matrix ()
SGVector< float64_tget_computed_dot_feature_vector (int32_t num)
void benchmark_add_to_dense_vector (int32_t repeats=5)
void benchmark_dense_dot_range (int32_t repeats=5)
virtual void * get_feature_iterator (int32_t vector_index)=0
virtual bool get_next_feature (int32_t &index, float64_t &value, void *iterator)=0
virtual void free_feature_iterator (void *iterator)=0
virtual SGVector< float64_tget_mean ()
virtual SGMatrix< float64_tget_cov ()

Static Public Member Functions

static void * dense_dot_range_helper (void *p)

Protected Member Functions

void display_progress (int32_t start, int32_t stop, int32_t v)

Protected Attributes

float64_t combined_weight
 feature weighting in combined dot features

Constructor & Destructor Documentation

CDotFeatures ( int32_t  size = 0)

constructor

Parameters:
sizecache size

Definition at line 42 of file DotFeatures.cpp.

CDotFeatures ( const CDotFeatures orig)

copy constructor

Definition at line 49 of file DotFeatures.cpp.

CDotFeatures ( CFile loader)

constructor

Parameters:
loaderFile object via which to load data

Definition at line 56 of file DotFeatures.cpp.

virtual ~CDotFeatures ( ) [virtual]

Definition at line 60 of file DotFeatures.h.


Member Function Documentation

virtual void add_to_dense_vec ( float64_t  alpha,
int32_t  vec_idx1,
float64_t vec2,
int32_t  vec2_len,
bool  abs_val = false 
) [pure virtual]

add vector 1 multiplied with alpha to dense vector2

Parameters:
alphascalar alpha
vec_idx1index of first vector
vec2pointer to real valued vector
vec2_lenlength of real valued vector
abs_valif true add the absolute value

Implemented in CSimpleFeatures< ST >, CSimpleFeatures< uint32_t >, CSimpleFeatures< float64_t >, CSimpleFeatures< T >, CSimpleFeatures< uint16_t >, CSparseFeatures< ST >, CSparseFeatures< float64_t >, CSparseFeatures< T >, CSparsePolyFeatures, CLBPPyrDotFeatures, CCombinedDotFeatures, CPolyFeatures, CHashedWDFeaturesTransposed, CHashedWDFeatures, CImplicitWeightedSpecFeatures, CExplicitSpecFeatures, CWDFeatures, and CSNPFeatures.

void benchmark_add_to_dense_vector ( int32_t  repeats = 5)

run benchmark for add_to_dense_vec

Definition at line 323 of file DotFeatures.cpp.

void benchmark_dense_dot_range ( int32_t  repeats = 5)

run benchmark for dense_dot_range

Definition at line 346 of file DotFeatures.cpp.

virtual float64_t dense_dot ( int32_t  vec_idx1,
const float64_t vec2,
int32_t  vec2_len 
) [pure virtual]
void dense_dot_range ( float64_t output,
int32_t  start,
int32_t  stop,
float64_t alphas,
float64_t vec,
int32_t  dim,
float64_t  b 
) [virtual]

Compute the dot product for a range of vectors. This function makes use of dense_dot alphas[i] * sparse[i]^T * w + b

Parameters:
outputresult for the given vector range
startstart vector range from this idx
stopstop vector range at this idx
alphasscalars to multiply with, may be NULL
vecdense vector to compute dot product with
dimlength of the dense vector
bbias

note that the result will be written to output[0...(stop-start-1)]

Reimplemented in CCombinedDotFeatures, and CHashedWDFeaturesTransposed.

Definition at line 62 of file DotFeatures.cpp.

void * dense_dot_range_helper ( void *  p) [static]

Compute the dot product for a range of vectors. This function is called by the threads created in dense_dot_range

Reimplemented in CHashedWDFeaturesTransposed.

Definition at line 226 of file DotFeatures.cpp.

void dense_dot_range_subset ( int32_t *  sub_index,
int32_t  num,
float64_t output,
float64_t alphas,
float64_t vec,
int32_t  dim,
float64_t  b 
) [virtual]

Compute the dot product for a subset of vectors. This function makes use of dense_dot alphas[i] * sparse[i]^T * w + b

Parameters:
sub_indexindex for which to compute outputs
numlength of index
outputresult for the given vector range
alphasscalars to multiply with, may be NULL
vecdense vector to compute dot product with
dimlength of the dense vector
bbias

Reimplemented in CCombinedDotFeatures, and CHashedWDFeaturesTransposed.

Definition at line 148 of file DotFeatures.cpp.

void display_progress ( int32_t  start,
int32_t  stop,
int32_t  v 
) [protected]

display progress output

Parameters:
startminimum value
stopmaximum value
vcurrent value

Definition at line 451 of file DotFeatures.cpp.

virtual float64_t dot ( int32_t  vec_idx1,
CDotFeatures df,
int32_t  vec_idx2 
) [pure virtual]

compute dot product between vector1 and vector2, appointed by their indices

Parameters:
vec_idx1index of first vector
dfDotFeatures (of same kind) to compute dot product with
vec_idx2index of second vector

Implemented in CSparseFeatures< ST >, CSparseFeatures< float64_t >, CSparseFeatures< T >, CSimpleFeatures< ST >, CSimpleFeatures< uint32_t >, CSimpleFeatures< float64_t >, CSimpleFeatures< T >, CSimpleFeatures< uint16_t >, CSparsePolyFeatures, CPolyFeatures, CLBPPyrDotFeatures, CCombinedDotFeatures, CHashedWDFeatures, CHashedWDFeaturesTransposed, CImplicitWeightedSpecFeatures, CExplicitSpecFeatures, CWDFeatures, and CSNPFeatures.

virtual void free_feature_iterator ( void *  iterator) [pure virtual]

get combined feature weight

Returns:
combined feature weight

Definition at line 144 of file DotFeatures.h.

compute the feature matrix in feature space

Returns:
computed feature matrix

Definition at line 279 of file DotFeatures.cpp.

compute the feature vector in feature space

Returns:
computed feature vector

Definition at line 306 of file DotFeatures.cpp.

SGMatrix< float64_t > get_cov ( ) [virtual]

get covariance

Returns:
covariance

Definition at line 407 of file DotFeatures.cpp.

virtual int32_t get_dim_feature_space ( ) const [pure virtual]
virtual void* get_feature_iterator ( int32_t  vector_index) [pure virtual]

iterate over the non-zero features

call get_feature_iterator first, followed by get_next_feature and free_feature_iterator to cleanup

Parameters:
vector_indexthe index of the vector over whose components to iterate over
Returns:
feature iterator (to be passed to get_next_feature)

Implemented in CSparseFeatures< ST >, CSparseFeatures< float64_t >, CSparseFeatures< T >, CSimpleFeatures< ST >, CSimpleFeatures< uint32_t >, CSimpleFeatures< float64_t >, CSimpleFeatures< T >, CSimpleFeatures< uint16_t >, CHashedWDFeaturesTransposed, CCombinedDotFeatures, CImplicitWeightedSpecFeatures, CPolyFeatures, CWDFeatures, CHashedWDFeatures, CSparsePolyFeatures, CExplicitSpecFeatures, CLBPPyrDotFeatures, and CSNPFeatures.

SGVector< float64_t > get_mean ( ) [virtual]

get mean

Returns:
mean returned

Definition at line 389 of file DotFeatures.cpp.

virtual bool get_next_feature ( int32_t &  index,
float64_t value,
void *  iterator 
) [pure 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

Parameters:
indexis returned by reference (-1 when not available)
valueis returned by reference
iteratoras returned by get_first_feature
Returns:
true if a new non-zero feature got returned

Implemented in CSparseFeatures< ST >, CSparseFeatures< float64_t >, CSparseFeatures< T >, CSimpleFeatures< ST >, CSimpleFeatures< uint32_t >, CSimpleFeatures< float64_t >, CSimpleFeatures< T >, CSimpleFeatures< uint16_t >, CHashedWDFeaturesTransposed, CCombinedDotFeatures, CImplicitWeightedSpecFeatures, CPolyFeatures, CWDFeatures, CHashedWDFeatures, CSparsePolyFeatures, CExplicitSpecFeatures, CLBPPyrDotFeatures, and CSNPFeatures.

virtual int32_t get_nnz_features_for_vector ( int32_t  num) [pure virtual]

set combined kernel weight

Parameters:
nwnew combined feature weight

Definition at line 150 of file DotFeatures.h.


Member Data Documentation

feature weighting in combined dot features

Definition at line 227 of file DotFeatures.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation