LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
tf_graph.h
Go to the documentation of this file.
1 
10 #ifndef Graph_h
11 #define Graph_h
12 
13 #include <memory>
14 #include <vector>
15 #include <string>
16 
17 namespace tensorflow
18 {
19  class Session;
20  class Tensor;
21 }
22 
23 namespace tf
24 {
25 
26 class Graph
27 {
28 public:
29  static std::unique_ptr<Graph> create(const char* graph_file_name, const std::vector<std::string> & outputs = {})
30  {
31  bool success;
32  std::unique_ptr<Graph> ptr(new Graph(graph_file_name, outputs, success));
33  if (success) { return ptr; }
34  else { return nullptr; }
35  }
36 
37  ~Graph();
38 
39  std::vector<float> run(const std::vector< std::vector<float> > & x);
40 
41  // process vector of 3D inputs, return vector of 1D outputs; use all inputs
42  // if samples = -1, or only the specified number of first samples
43  std::vector< std::vector<float> > run(
44  const std::vector< std::vector< std::vector< std::vector<float> > > > & x,
45  long long int samples = -1);
46  std::vector< std::vector< float > > run(const tensorflow::Tensor & x);
47 
48 private:
50  Graph(const char* graph_file_name, const std::vector<std::string> & outputs, bool & success);
51 
52  tensorflow::Session* fSession;
53  std::string fInputName;
54  std::vector< std::string > fOutputNames;
55 };
56 
57 } // namespace tf
58 
59 #endif
Float_t x
Definition: compare.C:6
std::string fInputName
Definition: tf_graph.h:53
Definition: tf_graph.h:23
static std::unique_ptr< Graph > create(const char *graph_file_name, const std::vector< std::string > &outputs={})
Definition: tf_graph.h:29
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
std::vector< std::string > fOutputNames
Definition: tf_graph.h:54
tensorflow::Session * fSession
Definition: tf_graph.h:52