Expert for the ONNX MVA method.
More...
#include <ONNX.h>
|
virtual void | load (Weightfile &weightfile) override |
| Load the expert from a Weightfile.
|
|
virtual std::vector< float > | apply (Dataset &testData) const override |
| Apply this expert onto a dataset.
|
|
virtual std::vector< std::vector< float > > | applyMulticlass (Dataset &test_data) const override |
| Apply this expert onto a dataset and return multiple outputs.
|
|
|
void | run (ONNXTensorView &view) const |
| Run the current inputs through the onnx model Will retrieve and fill the buffers from the view.
|
|
Expert for the ONNX MVA method.
Definition at line 149 of file ONNX.h.
◆ apply()
std::vector< float > apply |
( |
Dataset & | testData | ) |
const |
|
overridevirtual |
Apply this expert onto a dataset.
- Parameters
-
Implements Expert.
Definition at line 45 of file ONNX.cc.
46{
47 auto view = ONNXTensorView(testData, 1);
48 std::vector<float> result;
53 result.push_back(view.outputData()[0]);
54 }
55 return result;
56}
virtual unsigned int getNumberOfEvents() const =0
Returns the number of events in this dataset.
virtual void loadEvent(unsigned int iEvent)=0
Load the event number iEvent.
void run(ONNXTensorView &view) const
Run the current inputs through the onnx model Will retrieve and fill the buffers from the view.
◆ applyMulticlass()
std::vector< std::vector< float > > applyMulticlass |
( |
Dataset & | test_data | ) |
const |
|
overridevirtual |
Apply this expert onto a dataset and return multiple outputs.
- Parameters
-
Reimplemented from Expert.
Definition at line 58 of file ONNX.cc.
59{
61 std::vector<std::vector<float>> result(testData.getNumberOfEvents(),
63 for (unsigned int iEvent = 0; iEvent < testData.getNumberOfEvents(); ++iEvent) {
64 testData.loadEvent(iEvent);
66 auto outputs = view.outputData();
68 result[iEvent][iClass] = outputs[iClass];
69 }
70 }
71 return result;
72}
GeneralOptions m_general_options
General options loaded from the weightfile.
unsigned int m_nClasses
Number of classes in a classification problem.
◆ load()
Load the expert from a Weightfile.
- Parameters
-
weightfile | containing all information necessary to build the expert |
Implements Expert.
Definition at line 17 of file ONNX.cc.
18{
20 weightfile.
getFile(
"ONNX_Modelfile", onnxModelFileName);
22
23
24
25
26
27
28
29
30
34
36}
Ort::Env m_env
Environment object for ONNX session.
std::unique_ptr< Ort::Session > m_session
The ONNX inference session.
Ort::SessionOptions m_sessionOptions
ONNX session configuration.
void getOptions(Options &options) const
Fills an Option object from the xml tree.
std::string generateFileName(const std::string &suffix="")
Returns a temporary filename with the given suffix.
void getFile(const std::string &identifier, const std::string &custom_weightfile)
Creates a file from our weightfile (mostly this will be a weightfile of an MVA library)
◆ run()
Run the current inputs through the onnx model Will retrieve and fill the buffers from the view.
Definition at line 38 of file ONNX.cc.
39{
43}
Ort::RunOptions m_runOptions
Options to be passed to Ort::Session::Run.
const char * m_inputNames[1]
Input tensor names.
const char * m_outputNames[1]
Output tensor names.
◆ m_env
◆ m_general_options
General options loaded from the weightfile.
Definition at line 70 of file Expert.h.
◆ m_inputNames
const char* m_inputNames[1] = {"input"} |
|
private |
Input tensor names.
Definition at line 199 of file ONNX.h.
◆ m_outputNames
const char* m_outputNames[1] = {"output"} |
|
private |
Output tensor names.
Definition at line 204 of file ONNX.h.
◆ m_runOptions
Ort::RunOptions m_runOptions |
|
private |
Options to be passed to Ort::Session::Run.
Definition at line 194 of file ONNX.h.
◆ m_session
std::unique_ptr<Ort::Session> m_session |
|
private |
The ONNX inference session.
Definition at line 189 of file ONNX.h.
◆ m_sessionOptions
Ort::SessionOptions m_sessionOptions |
|
private |
ONNX session configuration.
Definition at line 184 of file ONNX.h.
The documentation for this class was generated from the following files: