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

Method separation_oracle

tools/python/src/svm_struct.cpp:45–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43 }
44
45 virtual void separation_oracle (
46 const long idx,
47 const matrix_type& current_solution,
48 scalar_type& loss,
49 feature_vector_type& psi
50 ) const
51 {
52 py::object res = problem.attr("separation_oracle")(idx,std::ref(current_solution));
53 pyassert(len(res) == 2, "separation_oracle() must return two objects, the loss and the psi vector");
54 py::tuple t = res.cast<py::tuple>();
55 // let the user supply the output arguments in any order.
56 try {
57 loss = t[0].cast<scalar_type>();
58 psi = t[1].cast<feature_vector_type&>();
59 } catch(py::cast_error&) {
60 psi = t[0].cast<feature_vector_type&>();
61 loss = t[1].cast<scalar_type>();
62 }
63 }
64
65private:
66

Callers

nothing calls this directly

Calls 3

refFunction · 0.85
lenFunction · 0.85
attrMethod · 0.80

Tested by

no test coverage detected