LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
nnet::ModelInterface Class Referenceabstract

#include "PointIdAlg.h"

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

Public Member Functions

virtual ~ModelInterface (void)
 
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

 ModelInterface (void)
 
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 49 of file PointIdAlg.h.

Constructor & Destructor Documentation

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

Definition at line 52 of file PointIdAlg.h.

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

52 { }
nnet::ModelInterface::ModelInterface ( void  )
inlineprotected

Definition at line 58 of file PointIdAlg.h.

References findFile().

58 { }

Member Function Documentation

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

Definition at line 51 of file PointIdAlg.cxx.

References art::errors::NotFound.

Referenced by ModelInterface(), and nnet::TfModelInterface::TfModelInterface().

52 {
53  std::string fname_out;
54  cet::search_path sp("FW_SEARCH_PATH");
55  if (!sp.find_file(fileName, fname_out))
56  {
57  struct stat buffer;
58  if (stat(fileName, &buffer) == 0) { fname_out = fileName; }
59  else
60  {
62  << "Could not find the model file " << fileName;
63  }
64  }
65  return fname_out;
66 }
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 35 of file PointIdAlg.cxx.

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

36 {
37  if ((samples == 0) || inps.empty() || inps.front().empty() || inps.front().front().empty())
38  return std::vector< std::vector<float> >();
39 
40  if ((samples == -1) || (samples > (int)inps.size())) { samples = inps.size(); }
41 
42  std::vector< std::vector<float> > results;
43  for (int i = 0; i < samples; ++i)
44  {
45  results.push_back(Run(inps[i]));
46  }
47  return results;
48 }
virtual std::vector< float > Run(std::vector< std::vector< float > > const &inp2d)=0
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265

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