23 using namespace shogun;
25 #ifndef DOXYGEN_SHOULD_SKIP_THIS
26 struct DF_THREAD_PARAM
39 #endif // DOXYGEN_SHOULD_SKIP_THIS
50 :
CFeatures(orig), combined_weight(orig.combined_weight)
72 int32_t num_vectors=stop-start;
84 DF_THREAD_PARAM params;
86 params.sub_index=NULL;
94 params.progress=
false;
100 pthread_t* threads =
SG_MALLOC(pthread_t, num_threads-1);
101 DF_THREAD_PARAM* params =
SG_MALLOC(DF_THREAD_PARAM, num_threads);
102 int32_t step= num_vectors/num_threads;
106 for (t=0; t<num_threads-1; t++)
109 params[t].sub_index=NULL;
110 params[t].output = output;
111 params[t].start = start+t*step;
112 params[t].stop = start+(t+1)*step;
113 params[t].alphas=alphas;
117 params[t].progress =
false;
118 pthread_create(&threads[t], NULL,
123 params[t].output = output;
124 params[t].sub_index=NULL;
125 params[t].start = start+t*step;
126 params[t].stop = stop;
127 params[t].alphas=alphas;
131 params[t].progress =
false;
134 for (t=0; t<num_threads-1; t++)
135 pthread_join(threads[t], NULL);
144 SG_INFO(
"prematurely stopped. \n");
162 DF_THREAD_PARAM params;
164 params.sub_index=sub_index;
165 params.output=output;
168 params.alphas=alphas;
172 params.progress=
false;
178 pthread_t* threads =
SG_MALLOC(pthread_t, num_threads-1);
179 DF_THREAD_PARAM* params =
SG_MALLOC(DF_THREAD_PARAM, num_threads);
180 int32_t step= num/num_threads;
184 for (t=0; t<num_threads-1; t++)
187 params[t].sub_index=sub_index;
188 params[t].output = output;
189 params[t].start = t*step;
190 params[t].stop = (t+1)*step;
191 params[t].alphas=alphas;
195 params[t].progress =
false;
196 pthread_create(&threads[t], NULL,
201 params[t].sub_index=sub_index;
202 params[t].output = output;
203 params[t].start = t*step;
204 params[t].stop = num;
205 params[t].alphas=alphas;
209 params[t].progress =
false;
212 for (t=0; t<num_threads-1; t++)
213 pthread_join(threads[t], NULL);
222 SG_INFO(
"prematurely stopped. \n");
228 DF_THREAD_PARAM* par=(DF_THREAD_PARAM*) p;
230 int32_t* sub_index=par->sub_index;
232 int32_t start=par->start;
233 int32_t stop=par->stop;
236 int32_t dim=par->dim;
238 bool progress=par->progress;
243 for (int32_t i=start; i<stop i++)
245 for (int32_t i=start; i<stop &&
250 output[i]=alphas[sub_index[i]]*df->
dense_dot(sub_index[i], vec, dim)+bias;
252 output[i]=df->
dense_dot(sub_index[i], vec, dim)+bias;
261 for (int32_t i=start; i<stop i++)
263 for (int32_t i=start; i<stop &&
268 output[i]=alphas[i]*df->
dense_dot(i, vec, dim)+bias;
270 output[i]=df->
dense_dot(i, vec, dim)+bias;
289 int64_t sz=((uint64_t) num)* dim;
297 for (int32_t i=0; i<num; i++)
333 for (int32_t r=0; r<repeats; r++)
335 for (int32_t i=0; i<num; i++)
339 SG_PRINT(
"Time to process %d x num=%d add_to_dense_vector ops: cputime %fs walltime %fs\n",
362 for (int32_t r=0; r<repeats; r++)
365 #ifdef DEBUG_DOTFEATURES
369 for (int32_t r=0; r<repeats; r++)
372 for (int32_t i=0; i<num; i++)
373 out2[i]+=
dense_dot(i, w, d)*alphas[i]+23;
376 for (int32_t i=0; i<num; i++)
380 SG_PRINT(
"Time to process %d x num=%d dense_dot_range ops: cputime %fs walltime %fs\n",
399 for (
int i = 0; i < num; i++)
401 for (
int j = 0; j < dim; j++)
420 for (
int i = 0; i < num; i++)
424 for (
int m = 0; m < v.
vlen; m++)
426 for (
int n = 0; n <= m ; n++)
433 for (
int m = 0; m < dim; m++)
435 for (
int n = 0; n <= m ; n++)
437 (cov.
matrix)[m*dim+n] /= num;
440 for (
int m = 0; m < dim-1; m++)
442 for (
int n = m+1; n < dim; n++)
453 int32_t num_vectors=stop-start;
456 if ( (i% (num_vectors/100+1))== 0)
460 void CDotFeatures::init()
464 "Feature weighting in combined dot features.");