|
| PointIdAlgTf (fhicl::Table< Config > const &table) |
|
std::vector< float > | Run (std::vector< std::vector< float >> const &inp2d) const override |
|
std::vector< std::vector< float > > | Run (std::vector< std::vector< std::vector< float >>> const &inps, int samples=-1) const override |
|
|
std::string | findFile (const char *fileName) const |
|
Definition at line 20 of file PointIdAlgTf_tool.cc.
PointIdAlgTools::PointIdAlgTf::PointIdAlgTf |
( |
fhicl::Table< Config > const & |
table | ) |
|
|
explicit |
Definition at line 38 of file PointIdAlgTf_tool.cc.
References tf::Graph::create(), findFile(), fNNetModelFilePath, fNNetOutputPattern, g, and art::errors::Unknown.
41 fNNetOutputs = table().NNetOutputs();
42 fPatchSizeW = table().PatchSizeW();
43 fPatchSizeD = table().PatchSizeD();
44 fCurrentWireIdx = 99999;
45 fCurrentScaledDrift = 99999;
53 std::vector<std::string> vs_cfgvr;
66 mf::LogError(
"PointIdAlgTf") <<
"File name extension not supported.";
static std::unique_ptr< Graph > create(const char *graph_file_name, const std::vector< std::string > &outputs={}, bool use_bundle=false, int ninputs=1, int noutputs=1)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::string PointIdAlgTools::PointIdAlgTf::findFile |
( |
const char * |
fileName | ) |
const |
|
protected |
Definition at line 73 of file PointIdAlgTf_tool.cc.
References art::errors::NotFound.
Referenced by PointIdAlgTf().
75 std::string fname_out;
76 cet::search_path sp(
"FW_SEARCH_PATH");
77 if (!sp.find_file(fileName, fname_out)) {
79 if (stat(fileName, &buffer) == 0) { fname_out = fileName; }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::vector< float > PointIdAlgTools::PointIdAlgTf::Run |
( |
std::vector< std::vector< float >> const & |
inp2d | ) |
const |
|
override |
Definition at line 88 of file PointIdAlgTf_tool.cc.
References g, and r.
90 long long int rows = inp2d.size(), cols = inp2d.front().size();
92 std::vector<tensorflow::Tensor> _x;
94 tensorflow::Tensor(tensorflow::DT_FLOAT, tensorflow::TensorShape({1, rows, cols, 1})));
95 auto input_map = _x[0].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->runx(_x);
107 return std::vector<float>();
std::vector< std::vector< float > > PointIdAlgTools::PointIdAlgTf::Run |
( |
std::vector< std::vector< std::vector< float >>> const & |
inps, |
|
|
int |
samples = -1 |
|
) |
| const |
|
override |
Definition at line 111 of file PointIdAlgTf_tool.cc.
References DEFINE_ART_CLASS_TOOL, g, and r.
116 if ((samples == 0) || inps.empty() || inps.front().empty() || inps.front().front().empty()) {
117 return std::vector<std::vector<float>>();
120 if ((samples == -1) || (samples > (
long long int)inps.size())) { samples = inps.size(); }
122 long long int rows = inps.front().size(), cols = inps.front().front().size();
124 std::vector<tensorflow::Tensor> _x;
126 tensorflow::Tensor(tensorflow::DT_FLOAT, tensorflow::TensorShape({samples, rows, cols, 1})));
127 auto input_map = _x[0].tensor<float, 4>();
128 for (
long long int s = 0; s < samples; ++s) {
129 const auto& sample = inps[s];
130 for (
long long int r = 0;
r < rows; ++
r) {
131 const auto& row = sample[
r];
132 for (
long long int c = 0; c < cols; ++c) {
133 input_map(s,
r, c, 0) = row[c];
std::string PointIdAlgTools::PointIdAlgTf::fNNetModelFilePath |
|
private |
std::vector<std::string> PointIdAlgTools::PointIdAlgTf::fNNetOutputPattern |
|
private |
std::unique_ptr<tf::Graph> PointIdAlgTools::PointIdAlgTf::g |
|
private |
The documentation for this class was generated from the following file: