MCPcopy Create free account
hub / github.com/davisking/dlib / build_cache

Method build_cache

dlib/svm/pegasos.h:424–451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

422 K real_kernel;
423
424 void build_cache (
425 ) const
426 {
427 std::sort(cache->frequency_of_use.rbegin(), cache->frequency_of_use.rend());
428 counter = 0;
429
430
431 cache->kernel.set_size(cache_size, samples->size());
432 cache->sample_location.assign(samples->size(), -1);
433
434 // loop over all the samples in the cache
435 for (long i = 0; i < cache_size; ++i)
436 {
437 const long cur = cache->frequency_of_use[i].second;
438 cache->sample_location[cur] = i;
439
440 // now populate all possible kernel products with the current sample
441 for (long j = 0; j < samples->size(); ++j)
442 {
443 cache->kernel(i, j) = real_kernel((*samples)(cur), (*samples)(j));
444 }
445
446 }
447
448 // reset the frequency of use metrics
449 for (long i = 0; i < samples->size(); ++i)
450 cache->frequency_of_use[i] = std::make_pair(0, i);
451 }
452
453
454 struct cache_type

Callers

nothing calls this directly

Calls 5

rbeginMethod · 0.80
rendMethod · 0.80
set_sizeMethod · 0.45
sizeMethod · 0.45
assignMethod · 0.45

Tested by

no test coverage detected