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

Class empirical_kernel_map

dlib/svm/empirical_kernel_map.h:46–416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44
45 template <typename kern_type>
46 class empirical_kernel_map
47 {
48 public:
49
50 struct empirical_kernel_map_error : public error
51 {
52 empirical_kernel_map_error(const std::string& message): error(message) {}
53 };
54
55 typedef kern_type kernel_type;
56 typedef typename kernel_type::sample_type sample_type;
57 typedef typename kernel_type::scalar_type scalar_type;
58 typedef typename kernel_type::mem_manager_type mem_manager_type;
59
60 void clear (
61 )
62 {
63 empirical_kernel_map().swap(*this);
64 }
65
66 template <typename T>
67 void load(
68 const kernel_type& kernel_,
69 const T& basis_samples
70 )
71 {
72 load_impl(kernel_, mat(basis_samples));
73 }
74
75 void load(
76 const linearly_independent_subset_finder<kernel_type>& lisf
77 )
78 {
79 if (lisf.size() == 0)
80 {
81 std::ostringstream sout;
82 sout << "An empty linearly_independent_subset_finder was supplied to the\n"
83 << "empirical_kernel_map::load() function. One reason this might occur\n"
84 << "is if your dataset contains only zero vectors (or vectors \n"
85 << "approximately zero).\n";
86 clear();
87 throw empirical_kernel_map_error(sout.str());
88 }
89
90 kernel = lisf.get_kernel();
91 weights = trans(chol(lisf.get_inv_kernel_marix()));
92 basis.resize(lisf.size());
93 for (unsigned long i = 0; i < basis.size(); ++i)
94 basis[i] = lisf[i];
95
96 }
97
98 const kernel_type get_kernel (
99 ) const
100 {
101 // make sure requires clause is not broken
102 DLIB_ASSERT(out_vector_size() > 0,
103 "\tconst kernel_type empirical_kernel_map::get_kernel()"

Callers 1

clearMethod · 0.70

Calls 3

kernel_matrixFunction · 0.85
absFunction · 0.85
dotFunction · 0.70

Tested by

no test coverage detected