24 std::vector<float>
Run(
std::vector<std::vector<float>>
const& inp2d)
const override;
26 int samples = -1)
const override;
32 std::unique_ptr<tf::Graph>
g;
53 std::vector<std::string> vs_cfgvr;
66 mf::LogError(
"PointIdAlgTf") <<
"File name extension not supported.";
80 if (
stat(fileName, &buffer) == 0) { fname_out =
fileName; }
92 long long int rows = inp2d.size(), cols = inp2d.front().size();
94 tensorflow::Tensor _x(tensorflow::DT_FLOAT, tensorflow::TensorShape({1, rows, cols, 1}));
95 auto input_map = _x.tensor<
float, 4>();
96 for (
long long int r = 0;
r < rows; ++
r) {
97 const auto&
row = inp2d[
r];
98 for (
long long int c = 0;
c < cols; ++
c) {
99 input_map(0,
r,
c, 0) =
row[
c];
103 auto out =
g->run(_x);
107 return std::vector<float>();
111 std::vector<std::vector<float>>
115 if ((samples == 0) || inps.empty() || inps.front().empty() || inps.front().front().empty()) {
116 return std::vector<std::vector<float>>();
119 if ((samples == -1) || (samples > (
long long int)inps.size())) { samples = inps.size(); }
121 long long int rows = inps.front().size(), cols = inps.front().front().size();
123 tensorflow::Tensor _x(tensorflow::DT_FLOAT, tensorflow::TensorShape({samples, rows, cols, 1}));
124 auto input_map = _x.tensor<
float, 4>();
125 for (
long long int s = 0;
s < samples; ++
s) {
126 const auto& sample = inps[
s];
127 for (
long long int r = 0;
r < rows; ++
r) {
128 const auto&
row = sample[
r];
129 for (
long long int c = 0;
c < cols; ++
c) {
130 input_map(
s,
r,
c, 0) =
row[
c];
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
DataProviderAlg(const fhicl::ParameterSet &pset)
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
static std::unique_ptr< Graph > create(const char *graph_file_name, const std::vector< std::string > &outputs={}, int ninputs=1, int noutputs=1)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::string find_file(std::string const &filename) const