SHOGUN
v1.1.0
|
Features that support dot products among other operations.
DotFeatures support the following operations:
dot product between feature vectors:
dot product between feature vector and a dense vector :
multiplication with a scalar and addition to a dense vector
:
Definition at line 41 of file DotFeatures.h.
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_t > | get_computed_dot_feature_matrix () |
SGVector< float64_t > | get_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_t > | get_mean () |
virtual SGMatrix< float64_t > | get_cov () |
![]() | |
CFeatures (int32_t size=0) | |
CFeatures (const CFeatures &orig) | |
CFeatures (CFile *loader) | |
virtual CFeatures * | duplicate () const =0 |
virtual | ~CFeatures () |
virtual EFeatureType | get_feature_type ()=0 |
virtual EFeatureClass | get_feature_class ()=0 |
virtual int32_t | add_preprocessor (CPreprocessor *p) |
set preprocessor | |
virtual CPreprocessor * | del_preprocessor (int32_t num) |
del current preprocessor | |
CPreprocessor * | get_preprocessor (int32_t num) |
get current preprocessor | |
void | set_preprocessed (int32_t num) |
bool | is_preprocessed (int32_t num) |
int32_t | get_num_preprocessed () |
get whether specified preprocessor (or all if num=1) was/were already applied | |
int32_t | get_num_preprocessors () const |
void | clean_preprocessors () |
int32_t | get_cache_size () |
virtual int32_t | get_num_vectors () const =0 |
virtual bool | reshape (int32_t num_features, int32_t num_vectors) |
virtual int32_t | get_size ()=0 |
void | list_feature_obj () |
virtual void | load (CFile *loader) |
virtual void | save (CFile *writer) |
bool | check_feature_compatibility (CFeatures *f) |
bool | has_property (EFeatureProperty p) |
void | set_property (EFeatureProperty p) |
void | unset_property (EFeatureProperty p) |
virtual void | set_subset (CSubset *subset) |
virtual void | remove_subset () |
virtual void | subset_changed_post () |
index_t | subset_idx_conversion (index_t idx) const |
bool | has_subset () const |
virtual CFeatures * | copy_subset (SGVector< index_t > indices) |
![]() | |
CSGObject () | |
CSGObject (const CSGObject &orig) | |
virtual | ~CSGObject () |
virtual const char * | get_name () const =0 |
virtual bool | is_generic (EPrimitiveType *generic) const |
template<class T > | |
void | set_generic () |
void | unset_generic () |
virtual void | print_serializable (const char *prefix="") |
virtual bool | save_serializable (CSerializableFile *file, const char *prefix="") |
virtual bool | load_serializable (CSerializableFile *file, const char *prefix="") |
void | set_global_io (SGIO *io) |
SGIO * | get_global_io () |
void | set_global_parallel (Parallel *parallel) |
Parallel * | get_global_parallel () |
void | set_global_version (Version *version) |
Version * | get_global_version () |
SGVector< char * > | get_modelsel_names () |
char * | get_modsel_param_descr (const char *param_name) |
index_t | get_modsel_param_index (const char *param_name) |
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 | |
![]() | |
CSubset * | m_subset |
Additional Inherited Members | |
![]() | |
SGIO * | io |
Parallel * | parallel |
Version * | version |
Parameter * | m_parameters |
Parameter * | m_model_selection_parameters |
CDotFeatures | ( | int32_t | size = 0 | ) |
CDotFeatures | ( | const CDotFeatures & | orig | ) |
copy constructor
Definition at line 49 of file DotFeatures.cpp.
CDotFeatures | ( | CFile * | loader | ) |
constructor
loader | File object via which to load data |
Definition at line 56 of file DotFeatures.cpp.
|
virtual |
Definition at line 60 of file DotFeatures.h.
|
pure virtual |
add vector 1 multiplied with alpha to dense vector2
alpha | scalar alpha |
vec_idx1 | index of first vector |
vec2 | pointer to real valued vector |
vec2_len | length of real valued vector |
abs_val | if 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.
|
pure virtual |
compute dot product between vector1 and a dense vector
vec_idx1 | index of first vector |
vec2 | pointer to real valued vector |
vec2_len | length of real valued vector |
Implemented in CSimpleFeatures< ST >, CSimpleFeatures< ST >, CSimpleFeatures< ST >, CSimpleFeatures< ST >, CSimpleFeatures< ST >, CSimpleFeatures< ST >, CSimpleFeatures< ST >, CSimpleFeatures< ST >, CSimpleFeatures< ST >, CSimpleFeatures< ST >, CSimpleFeatures< ST >, CSimpleFeatures< ST >, CSimpleFeatures< ST >, CSparseFeatures< ST >, CSparseFeatures< float64_t >, CSparseFeatures< T >, CSimpleFeatures< ST >, CSimpleFeatures< uint32_t >, CSimpleFeatures< float64_t >, CSimpleFeatures< T >, CSimpleFeatures< uint16_t >, CSparsePolyFeatures, CLBPPyrDotFeatures, CPolyFeatures, CCombinedDotFeatures, CHashedWDFeatures, CHashedWDFeaturesTransposed, CImplicitWeightedSpecFeatures, CExplicitSpecFeatures, CWDFeatures, and CSNPFeatures.
|
virtual |
Compute the dot product for a range of vectors. This function makes use of dense_dot alphas[i] * sparse[i]^T * w + b
output | result for the given vector range |
start | start vector range from this idx |
stop | stop vector range at this idx |
alphas | scalars to multiply with, may be NULL |
vec | dense vector to compute dot product with |
dim | length of the dense vector |
b | bias |
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.
|
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.
|
virtual |
Compute the dot product for a subset of vectors. This function makes use of dense_dot alphas[i] * sparse[i]^T * w + b
sub_index | index for which to compute outputs |
num | length of index |
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 |
Reimplemented in CCombinedDotFeatures, and CHashedWDFeaturesTransposed.
Definition at line 148 of file DotFeatures.cpp.
|
protected |
display progress output
start | minimum value |
stop | maximum value |
v | current value |
Definition at line 451 of file DotFeatures.cpp.
|
pure virtual |
compute dot product between vector1 and vector2, appointed by their indices
vec_idx1 | index of first vector |
df | DotFeatures (of same kind) to compute dot product with |
vec_idx2 | index 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.
|
pure virtual |
clean up iterator call this function with the iterator returned by get_first_feature
iterator | as returned by get_first_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.
float64_t get_combined_feature_weight | ( | ) |
get combined feature weight
Definition at line 144 of file DotFeatures.h.
compute the feature matrix in feature space
Definition at line 279 of file DotFeatures.cpp.
compute the feature vector in feature space
Definition at line 306 of file DotFeatures.cpp.
|
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 CSparseFeatures< ST >, CSparseFeatures< float64_t >, CSparseFeatures< T >, CSimpleFeatures< ST >, CSimpleFeatures< uint32_t >, CSimpleFeatures< float64_t >, CSimpleFeatures< T >, CSimpleFeatures< uint16_t >, CCombinedDotFeatures, CImplicitWeightedSpecFeatures, CHashedWDFeatures, CHashedWDFeaturesTransposed, CExplicitSpecFeatures, CWDFeatures, CSparsePolyFeatures, CPolyFeatures, CLBPPyrDotFeatures, and CSNPFeatures.
|
pure virtual |
iterate over the non-zero features
call get_feature_iterator first, followed by get_next_feature and free_feature_iterator to cleanup
vector_index | the index of the vector over whose components to iterate over |
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.
|
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
index | is returned by reference (-1 when not available) |
value | is returned by reference |
iterator | as returned by get_first_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.
|
pure virtual |
get number of non-zero features in vector
(in case accurate estimates are too expensive overestimating is OK)
num | which vector |
Implemented in CSimpleFeatures< ST >, CSimpleFeatures< uint32_t >, CSimpleFeatures< float64_t >, CSimpleFeatures< T >, CSimpleFeatures< uint16_t >, CSparseFeatures< ST >, CSparseFeatures< float64_t >, CSparseFeatures< T >, CExplicitSpecFeatures, CCombinedDotFeatures, CHashedWDFeaturesTransposed, CHashedWDFeatures, CImplicitWeightedSpecFeatures, CWDFeatures, CSNPFeatures, CSparsePolyFeatures, CPolyFeatures, and CLBPPyrDotFeatures.
void set_combined_feature_weight | ( | float64_t | nw | ) |
set combined kernel weight
nw | new combined feature weight |
Definition at line 150 of file DotFeatures.h.
|
protected |
feature weighting in combined dot features
Definition at line 227 of file DotFeatures.h.