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

Function add_normalized_df

tools/python/src/decision_functions.cpp:203–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201
202template <typename kernel_type>
203void add_normalized_df (
204 py::module& m,
205 const std::string name
206)
207{
208 using df_type = normalized_function<decision_function<kernel_type>>;
209
210 py::class_<df_type>(m, name.c_str())
211 .def("__call__", &normalized_predict<decision_function<kernel_type>>)
212 .def("__call__", &normalized_predict_np<decision_function<kernel_type>>)
213 .def("batch_predict", &normalized_predict_vec<decision_function<kernel_type>>)
214 .def("batch_predict", &normalized_predict_np_vec<decision_function<kernel_type>>)
215 .def_property_readonly("alpha", [](const df_type& df) {return df.function.alpha;})
216 .def_property_readonly("b", [](const df_type& df) {return df.function.b;})
217 .def_property_readonly("kernel_function", [](const df_type& df) {return df.function.kernel_function;})
218 .def_property_readonly("basis_vectors", [](const df_type& df) {
219 std::vector<matrix<double,0,1>> temp;
220 for (long i = 0; i < df.function.basis_vectors.size(); ++i)
221 temp.push_back(sparse_to_dense(df.function.basis_vectors(i)));
222 return temp;
223 })
224 .def_property_readonly("means", [](const df_type& df) {return df.normalizer.means();},
225 "Input vectors are normalized by the equation, (x-means)*invstd_devs, before being passed to the underlying RBF function.")
226 .def_property_readonly("invstd_devs", [](const df_type& df) {return df.normalizer.std_devs();},
227 "Input vectors are normalized by the equation, (x-means)*invstd_devs, before being passed to the underlying RBF function.")
228 .def(py::pickle(&getstate<df_type>, &setstate<df_type>));
229}
230
231template <typename df_type>
232typename df_type::sample_type get_weights(

Callers

nothing calls this directly

Calls 4

sparse_to_denseFunction · 0.85
pickleFunction · 0.85
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected