LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
nnet::ModelInterface Class Referenceabstract

#include "PointIdAlg.h"

Inheritance diagram for nnet::ModelInterface:
nnet::KerasModelInterface nnet::TfModelInterface

Public Member Functions

virtual ~ModelInterface ()
 
virtual std::vector< float > Run (std::vector< std::vector< float >> const &inp2d)=0
 
virtual std::vector< std::vector< float > > Run (std::vector< std::vector< std::vector< float >>> const &inps, int samples=-1)
 

Protected Member Functions

std::string findFile (const char *fileName) const
 

Detailed Description

Interface class for various classifier models. Now MLP (NetMaker) and CNN (Keras with simple cpp interface) are supported. Will add interface to Protobuf as soon as Tensorflow may be used from UPS.

Definition at line 60 of file PointIdAlg.h.

Constructor & Destructor Documentation

virtual nnet::ModelInterface::~ModelInterface ( )
inlinevirtual

Definition at line 62 of file PointIdAlg.h.

References lar::dump::vector().

62 {}

Member Function Documentation

std::string nnet::ModelInterface::findFile ( const char *  fileName) const
protected

Definition at line 67 of file PointIdAlg.cxx.

References art::errors::NotFound.

Referenced by nnet::TfModelInterface::TfModelInterface().

68 {
69  std::string fname_out;
70  cet::search_path sp("FW_SEARCH_PATH");
71  if (!sp.find_file(fileName, fname_out)) {
72  struct stat buffer;
73  if (stat(fileName, &buffer) == 0) { fname_out = fileName; }
74  else {
75  throw art::Exception(art::errors::NotFound) << "Could not find the model file " << fileName;
76  }
77  }
78  return fname_out;
79 }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
virtual std::vector<float> nnet::ModelInterface::Run ( std::vector< std::vector< float >> const &  inp2d)
pure virtual
std::vector< std::vector< float > > nnet::ModelInterface::Run ( std::vector< std::vector< std::vector< float >>> const &  inps,
int  samples = -1 
)
virtual

Reimplemented in nnet::TfModelInterface.

Definition at line 51 of file PointIdAlg.cxx.

References Run(), and lar::dump::vector().

54 {
55  if ((samples == 0) || inps.empty() || inps.front().empty() || inps.front().front().empty())
56  return std::vector<std::vector<float>>();
57 
58  if ((samples == -1) || (samples > (int)inps.size())) { samples = inps.size(); }
59 
60  std::vector<std::vector<float>> results;
61  for (int i = 0; i < samples; ++i) {
62  results.push_back(Run(inps[i]));
63  }
64  return results;
65 }
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
virtual std::vector< float > Run(std::vector< std::vector< float >> const &inp2d)=0

The documentation for this class was generated from the following files: