3 #include "larrecodnn/ImagePatternAlgs/ToolInterfaces/IWaveformRecog.h" 5 #include "tensorflow/core/public/session.h" 16 const std::vector<std::vector<float>>&)
const override;
19 std::unique_ptr<tf::Graph>
g;
31 pset.
get<std::vector<std::string>>(
"NNetOutputPattern", {
"cnn_output",
"dense_3"});
38 mf::LogInfo(
"WaveformRecogTf") <<
"TF model loaded.";
44 mf::LogInfo(
"WaveformRecogTf") <<
"TF model loaded.";
47 mf::LogError(
"WaveformRecogTf") <<
"File name extension not supported.";
50 setupWaveRecRoiParams(pset);
55 const std::vector<std::vector<float>>& waveforms)
const 57 if (waveforms.empty() || waveforms.front().empty()) {
58 return std::vector<std::vector<float>>();
61 long long int samples = waveforms.size(), numtcks = waveforms.front().size();
64 std::vector<tensorflow::Tensor> _x;
66 tensorflow::Tensor(tensorflow::DT_FLOAT, tensorflow::TensorShape({samples, numtcks, 1})));
67 auto input_map = _x[0].tensor<float, 3>();
68 for (
long long int s = 0; s < samples; ++s) {
69 const auto& wvfrm = waveforms[s];
70 for (
long long int t = 0; t < numtcks; ++t) {
71 input_map(s, t, 0) = wvfrm[t];
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
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
T get(std::string const &key) const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception