Public Member Functions | Protected Member Functions | List of all members
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 50 of file PointIdAlg.h.

Constructor & Destructor Documentation

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

Definition at line 52 of file PointIdAlg.h.

52 {}

Member Function Documentation

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

Definition at line 49 of file PointIdAlg.cxx.

50 {
51  std::string fname_out;
52  cet::search_path sp("FW_SEARCH_PATH");
53  if (!sp.find_file(fileName, fname_out)) {
54  struct stat buffer;
55  if (stat(fileName, &buffer) == 0) { fname_out = fileName; }
56  else {
57  throw art::Exception(art::errors::NotFound) << "Could not find the model file " << fileName;
58  }
59  }
60  return fname_out;
61 }
std::string string
Definition: nybbler.cc:12
fileName
Definition: dumpTree.py:9
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 34 of file PointIdAlg.cxx.

35 {
36  if ((samples == 0) || inps.empty() || inps.front().empty() || inps.front().front().empty())
37  return std::vector<std::vector<float>>();
38 
39  if ((samples == -1) || (samples > (int)inps.size())) { samples = inps.size(); }
40 
41  std::vector<std::vector<float>> results;
42  for (int i = 0; i < samples; ++i) {
43  results.push_back(Run(inps[i]));
44  }
45  return results;
46 }
struct vector vector
virtual std::vector< float > Run(std::vector< std::vector< float >> const &inp2d)=0

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