// Convenience wrapper around predict for models with
// single tensor outputs of shape (1, 1, 1),
// typically used for regression or binary classification.
// Returns this one activation value.
float_type predict_single_output(const tensor5s& inputs) const
{
const tensor5s outputs = predict(inputs);
internal::assertion(outputs.size() == 1,
"invalid number of outputs");
const auto output_shape = outputs.front().shape();
internal::assertion(output_shape.volume() == 1,
"invalid output shape");
return outputs.front().get(0, 0, 0, 0, 0);
}
convert tensor5 datatype to std::vector
const std::vector<float> result_vec = *result.front().as_vector();
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:frugally-deep: Header-only library for using Keras models in C++ - Python技术站