73 SG_ERROR(
"Kernel still initialized on destruction.\n")
78 SG_INFO(
"Kernel deleted (%p).\n",
this)
90 REQUIRE(l,
"CKernel::init(%p, %p): Left hand side features required!\n", l, r)
91 REQUIRE(r,
"CKernel::init(%p, %p): Right hand side features required!\n", l, r)
120 SG_DEBUG(
"leaving CKernel::init(%p, %p)\n", l, r)
170 SG_DEBUG(
"entering CKernel::remove_lhs_and_rhs\n")
182 SG_DEBUG(
"leaving CKernel::remove_lhs_and_rhs\n")
208 #define ENUM_CASE(n) case n: SG_INFO(#n " ") break; 215 "SLOWBUTMEMEFFICIENT");
326 int32_t count, int32_t *IDX,
float64_t * weights)
328 SG_ERROR(
"kernel does not support linadd optimization\n")
334 SG_ERROR(
"kernel does not support linadd optimization\n")
340 SG_ERROR(
"kernel does not support linadd optimization\n")
345 int32_t num_vec, int32_t* vec_idx,
float64_t* target, int32_t num_suppvec,
348 SG_ERROR(
"kernel does not support batch computation\n")
353 SG_ERROR(
"kernel does not support linadd optimization, add_to_normal not implemented\n")
358 SG_ERROR(
"kernel does not support linadd optimization, clear_normal not implemented\n")
367 int32_t vector_idx,
float64_t * subkernel_contrib)
369 SG_ERROR(
"kernel compute_by_subkernel not implemented\n")
389 SG_ERROR(
"number of subkernel weights should be one ...\n")
399 REQUIRE(casted,
"CKernel::obtain_from_generic(): Error, provided object" 400 " of class \"%s\" is not a subclass of CKernel!\n",
411 int32_t* sv_idx=SG_MALLOC(int32_t, num_suppvec);
414 for (int32_t i=0; i<num_suppvec; i++)
458 SG_ADD(&
num_lhs,
"num_lhs",
"Number of feature vectors on left hand side.",
460 SG_ADD(&
num_rhs,
"num_rhs",
"Number of feature vectors on right hand side.",
525 int32_t i_start=params->
start;
526 int32_t i_end=params->
end;
535 int64_t total=total_start;
537 for (int32_t i=i_start; i<i_end; i++)
544 for (int32_t j=j_start; j<n; j++)
549 if (symmetric && i!=j)
556 if (symmetric && i!=j)
582 int64_t total_num = int64_t(m)*n;
585 bool symmetric= (
lhs &&
lhs==
rhs && m==n);
587 SG_DEBUG(
"returning kernel matrix of size %dx%d\n", m, n)
589 result=SG_MALLOC(T, total_num);
605 get_kernel_matrix_helper<T>((
void*) ¶ms);
609 pthread_t* threads = SG_MALLOC(pthread_t, num_threads-1);
611 int64_t step= total_num/num_threads;
616 for (t=0; t<num_threads; t++)
619 params[t].
result = result;
629 int code=pthread_create(&threads[t], NULL,
630 CKernel::get_kernel_matrix_helper<T>, (
void*)¶ms[t]);
634 SG_WARNING(
"Thread creation failed (thread %d of %d) " 635 "with error:'%s'\n",t, num_threads, strerror(code));
642 params[t].
result = result;
651 get_kernel_matrix_helper<T>(¶ms[t]);
653 for (t=0; t<num_threads; t++)
655 if (pthread_join(threads[t], NULL) != 0)
656 SG_WARNING(
"pthread_join of thread %d/%d failed\n", t, num_threads)
671 template void* CKernel::get_kernel_matrix_helper<float64_t>(
void* p);
672 template void* CKernel::get_kernel_matrix_helper<float32_t>(
void* p);
virtual void clear_normal()
virtual const char * get_name() const =0
virtual void load_serializable_post()
virtual bool init(CFeatures *lhs, CFeatures *rhs)
int32_t get_num_support_vectors()
int32_t compute_row_start(int64_t offs, int32_t n, bool symmetric)
virtual void set_matrix(const bool *matrix, int32_t num_feat, int32_t num_vec)
virtual void compute_by_subkernel(int32_t vector_idx, float64_t *subkernel_contrib)
int32_t get_num_threads() const
int32_t num_rhs
number of feature vectors on right hand side
static void * get_kernel_matrix_helper(void *p)
Class ShogunException defines an exception which is thrown whenever an error inside of shogun occurs...
virtual bool set_normalizer(CKernelNormalizer *normalizer)
virtual int32_t get_num_vectors() const =0
virtual void save_serializable_pre()
virtual bool delete_optimization()
float64_t kernel(int32_t idx_a, int32_t idx_b)
virtual void remove_rhs()
takes all necessary steps if the rhs is removed from kernel
virtual int32_t get_num_vec_lhs()
SGMatrix< float64_t > get_kernel_matrix()
int32_t cache_size
cache_size in MB
bool get_is_initialized()
float64_t combined_kernel_weight
virtual void register_params()
virtual void remove_lhs_and_rhs()
virtual CKernelNormalizer * get_normalizer()
Class SGObject is the base class of all shogun objects.
#define SG_OBJ_PROGRESS(o,...)
virtual SGVector< float64_t > get_subkernel_weights()
virtual EFeatureType get_feature_type()=0
KERNELCACHE_ELEM * kernel_matrix
A File access base class.
virtual void save_serializable_post()
virtual float64_t compute_optimized(int32_t vector_idx)
EOptimizationType get_optimization_type()
virtual void save_serializable_post()
float64_t get_alpha(int32_t idx)
float64_t get_combined_kernel_weight()
virtual EFeatureClass get_feature_class() const =0
Identity Kernel Normalization, i.e. no normalization is applied.
int32_t num_lhs
number of feature vectors on left hand side
The class Kernel Normalizer defines a function to post-process kernel values.
int32_t get_support_vector(int32_t idx)
static bool cancel_computations()
virtual int32_t get_num_vec_rhs()
virtual void set_subkernel_weights(SGVector< float64_t > weights)
virtual bool init_normalizer()
bool optimization_initialized
EOptimizationType opt_type
virtual void load_serializable_post()
CFeatures * rhs
feature vectors to occur on right hand side
static CKernel * obtain_from_generic(CSGObject *kernel)
all of classes and functions are contained in the shogun namespace
virtual bool init(CKernel *k)=0
virtual void compute_batch(int32_t num_vec, int32_t *vec_idx, float64_t *target, int32_t num_suppvec, int32_t *IDX, float64_t *alphas, float64_t factor=1.0)
virtual EKernelType get_kernel_type()=0
virtual bool init_optimization(int32_t count, int32_t *IDX, float64_t *weights)
CFeatures * lhs
feature vectors to occur on left hand side
The class Features is the base class of all feature objects.
virtual void save_serializable_pre()
virtual void remove_lhs()
virtual int32_t get_num_subkernels()
bool init_optimization_svm(CSVM *svm)
A generic Support Vector Machine Interface.
CKernelNormalizer * normalizer
virtual bool has_features()
virtual void add_to_normal(int32_t vector_idx, float64_t weight)
virtual EFeatureType get_feature_type() const =0
virtual EFeatureClass get_feature_class()=0