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

Function normalized_predict_np_vec

tools/python/src/decision_functions.cpp:131–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129
130template <typename decision_function>
131py::array_t<double> normalized_predict_np_vec (
132 const normalized_function<decision_function>& df,
133 const numpy_image<double>& samps_
134)
135{
136 auto samps = make_image_view(samps_);
137
138 if (df.function.basis_vectors(0).size() != samps.nc())
139 {
140 std::ostringstream sout;
141 sout << "Input vector should have " << df.function.basis_vectors(0).size()
142 << " dimensions, not " << samps.nc() << ".";
143 PyErr_SetString( PyExc_ValueError, sout.str().c_str() );
144 throw py::error_already_set();
145 }
146
147 py::array_t<double, py::array::c_style> out((size_t)samps.nr());
148 matrix<double,0,1> temp(samps.nc());
149 auto data = out.mutable_data();
150 for (long r = 0; r < samps.nr(); ++r)
151 {
152 for (long c = 0; c < samps.nc(); ++c)
153 temp(c) = samps[r][c];
154 *data++ = df(temp);
155 }
156 return out;
157}
158
159template <typename decision_function>
160double normalized_predict_np (

Callers

nothing calls this directly

Calls 6

make_image_viewFunction · 0.85
sizeMethod · 0.45
ncMethod · 0.45
strMethod · 0.45
nrMethod · 0.45
mutable_dataMethod · 0.45

Tested by

no test coverage detected