15 using namespace shogun;
17 #ifndef DOXYGEN_SHOULD_SKIP_THIS
26 #endif // DOXYGEN_SHOULD_SKIP_THIS
29 :
CMachine(), kernel(NULL), use_batch_computation(true), use_linadd(true), use_bias(true)
58 int32_t * sv_idx =
SG_MALLOC(int32_t, num_sv);
61 for(int32_t i=0; i<num_sv; i++)
73 SG_ERROR(
"initialization of kernel optimization failed\n");
78 SG_ERROR(
"initialization of kernel optimization failed\n");
88 SG_ERROR(
"Kernelmachine can not proceed without kernel!\n");
95 SG_DEBUG(
"computing output on %d test examples\n", num_vectors);
108 memset(output, 0,
sizeof(
float64_t)*num_vectors);
114 int32_t* idx=
SG_MALLOC(int32_t, num_vectors);
117 for (int32_t i=0; i<num_vectors; i++)
133 for (int32_t i=0; i<num_vectors; i++)
145 S_THREAD_PARAM params;
146 params.kernel_machine=
this;
149 params.end=num_vectors;
156 pthread_t* threads =
SG_MALLOC(pthread_t, num_threads-1);
157 S_THREAD_PARAM* params =
SG_MALLOC(S_THREAD_PARAM, num_threads);
158 int32_t step= num_vectors/num_threads;
162 for (t=0; t<num_threads-1; t++)
164 params[t].kernel_machine =
this;
165 params[t].result = lab;
166 params[t].start = t*step;
167 params[t].end = (t+1)*step;
168 params[t].verbose =
false;
169 pthread_create(&threads[t], NULL,
173 params[t].kernel_machine =
this;
174 params[t].result = lab;
175 params[t].start = t*step;
176 params[t].end = num_vectors;
177 params[t].verbose =
true;
180 for (t=0; t<num_threads-1; t++)
181 pthread_join(threads[t], NULL);
191 SG_INFO(
"prematurely stopped. \n");
231 SG_ERROR(
"No vectors on left hand side\n");
241 S_THREAD_PARAM* params= (S_THREAD_PARAM*) p;
242 CLabels* result=params->result;
246 for (int32_t vec=params->start; vec<params->end; vec++)
248 for (int32_t vec=params->start; vec<params->end &&
254 int32_t num_vectors=params->end - params->start;
255 int32_t v=vec-params->start;
256 if ( (v% (num_vectors/100+1))== 0)
269 SG_ERROR(
"kernel is needed to store SV features.\n");
275 SG_ERROR(
"kernel lhs is needed to store SV features.\n");
virtual bool init(CFeatures *lhs, CFeatures *rhs)
SGVector< int32_t > m_svs
int32_t get_num_support_vectors()
bool set_label(int32_t idx, float64_t label)
int32_t get_num_threads() const
The class Labels models labels, i.e. class assignments of objects.
virtual int32_t get_num_vectors() const =0
float64_t kernel(int32_t idx_a, int32_t idx_b)
static void * apply_helper(void *p)
A generic KernelMachine interface.
A generic learning machine interface.
bool get_is_initialized()
SGVector< float64_t > m_alpha
bool has_property(EKernelProperty p)
virtual void store_model_features()
Class SGObject is the base class of all shogun objects.
bool get_batch_computation_enabled()
static void clear_cancel()
#define SG_ADD(param, name, description, ms_available)
virtual float64_t compute_optimized(int32_t vector_idx)
float64_t get_alpha(int32_t idx)
bool use_batch_computation
bool init_kernel_optimization()
int32_t get_support_vector(int32_t idx)
static bool cancel_computations()
virtual int32_t get_num_vec_rhs()
bool get_show_progress() const
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 bool init_optimization(int32_t count, int32_t *IDX, float64_t *weights)
virtual CFeatures * copy_subset(SGVector< index_t > indices)
The class Features is the base class of all feature objects.
#define SG_SPROGRESS(...)
virtual CLabels * apply()
virtual ~CKernelMachine()
static void range_fill_vector(T *vec, int32_t len, T start=0)
#define SG_MALLOC(type, len)