#include "PointIdAlg.h"
|
| TfModelInterface (const char *modelFileName) |
|
std::vector< std::vector< float > > | Run (std::vector< std::vector< std::vector< float > > > const &inps, int samples=-1) override |
|
std::vector< float > | Run (std::vector< std::vector< float > > const &inp2d) override |
|
|
std::string | findFile (const char *fileName) const |
|
Definition at line 76 of file PointIdAlg.h.
nnet::TfModelInterface::TfModelInterface |
( |
const char * |
modelFileName | ) |
|
Definition at line 97 of file PointIdAlg.cxx.
References tf::Graph::create(), nnet::ModelInterface::findFile(), and art::errors::Unknown.
102 mf::LogInfo(
"TfModelInterface") <<
"TF model loaded.";
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
static std::unique_ptr< Graph > create(const char *graph_file_name, const std::vector< std::string > &outputs={})
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::string findFile(const char *fileName) const
std::unique_ptr< tf::Graph > g
std::string nnet::ModelInterface::findFile |
( |
const char * |
fileName | ) |
const |
|
protectedinherited |
std::vector< std::vector< float > > nnet::TfModelInterface::Run |
( |
std::vector< std::vector< std::vector< float > > > const & |
inps, |
|
|
int |
samples = -1 |
|
) |
| |
|
overridevirtual |
Reimplemented from nnet::ModelInterface.
Definition at line 106 of file PointIdAlg.cxx.
References s, and lar::dump::vector().
108 if ((samples == 0) || inps.empty() || inps.front().empty() || inps.front().front().empty())
111 if ((samples == -1) || (samples > (
long long int)inps.size())) { samples = inps.size(); }
113 long long int rows = inps.front().size(), cols = inps.front().front().size();
115 tensorflow::Tensor _x(tensorflow::DT_FLOAT, tensorflow::TensorShape({ samples, rows, cols, 1 }));
116 auto input_map = _x.tensor<float, 4>();
117 for (
long long int s = 0;
s < samples; ++
s) {
118 const auto & sample = inps[
s];
119 for (
long long int r = 0; r < rows; ++r) {
120 const auto & row = sample[r];
121 for (
long long int c = 0; c < cols; ++c) {
122 input_map(
s, r, c, 0) = row[c];
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::unique_ptr< tf::Graph > g
std::vector< float > nnet::TfModelInterface::Run |
( |
std::vector< std::vector< float > > const & |
inp2d | ) |
|
|
overridevirtual |
Implements nnet::ModelInterface.
Definition at line 131 of file PointIdAlg.cxx.
133 long long int rows = inp2d.size(), cols = inp2d.front().size();
135 tensorflow::Tensor _x(tensorflow::DT_FLOAT, tensorflow::TensorShape({ 1, rows, cols, 1 }));
136 auto input_map = _x.tensor<float, 4>();
137 for (
long long int r = 0; r < rows; ++r) {
138 const auto & row = inp2d[r];
139 for (
long long int c = 0; c < cols; ++c) {
140 input_map(0, r, c, 0) = row[c];
144 auto out =
g->run(_x);
145 if (!out.empty())
return out.front();
146 else return std::vector<float>();
std::unique_ptr< tf::Graph > g
std::unique_ptr<tf::Graph> nnet::TfModelInterface::g |
|
private |
The documentation for this class was generated from the following files:
- /cvmfs/larsoft.opensciencegrid.org/products/larreco/v07_10_02/source/larreco/RecoAlg/ImagePatternAlgs/Tensorflow/PointIdAlg/PointIdAlg.h
- /cvmfs/larsoft.opensciencegrid.org/products/larreco/v07_10_02/source/larreco/RecoAlg/ImagePatternAlgs/Tensorflow/PointIdAlg/PointIdAlg.cxx