2#ifndef RIVET_RivetLWTNN_HH
3#define RIVET_RivetLWTNN_HH
5#include "Rivet/Tools/RivetPaths.hh"
6#include "lwtnn/LightweightNeuralNetwork.hh"
7#include "lwtnn/LightweightGraph.hh"
8#include "lwtnn/Exceptions.hh"
9#include "lwtnn/parse_json.hh"
22 input = std::ifstream(jsonpath);
23 return lwt::parse_json(input);
24 }
catch (lwt::LightweightNNException &e) {
26 throw IOError(
"Error loading LWTNN JSON config");
39 input = std::ifstream(jsonpath);
40 return lwt::parse_json_graph(input);
41 }
catch (lwt::LightweightNNException &e) {
43 throw IOError(
"Error loading LWTNN JSON config");
48 std::unique_ptr<lwt::LightweightNeuralNetwork>
mkLWTNN(
const lwt::JSONConfig& jsonconfig) {
50 return std::make_unique<lwt::LightweightNeuralNetwork>(jsonconfig.inputs, jsonconfig.layers, jsonconfig.outputs);
51 }
catch (lwt::LightweightNNException &e) {
52 throw IOError(
"Error initialising from LWTNN JSON config");
59 std::unique_ptr<lwt::LightweightGraph>
mkGraphLWTNN(
const lwt::GraphConfig& graphconfig) {
61 return std::make_unique<lwt::LightweightGraph>(graphconfig);
62 }
catch (lwt::LightweightNNException &e) {
63 throw IOError(
"Error initialising from LWTNN JSON config");
69 std::unique_ptr<lwt::LightweightNeuralNetwork>
mkLWTNN(
const string& jsonpath) {
77 std::unique_ptr<lwt::LightweightGraph>
mkGraphLWTNN(
const string& jsonpath) {
Definition MC_CENT_PPB_Projections.hh:10
lwt::JSONConfig readLWTNNConfig(const string &jsonpath)
Read a LWT DNN config from the JSON path.
Definition RivetLWTNN.hh:17
lwt::GraphConfig readLWTNNGraphConfig(const string &jsonpath)
Read a LWT Graph config from the JSON path.
Definition RivetLWTNN.hh:34
std::unique_ptr< lwt::LightweightNeuralNetwork > mkLWTNN(const lwt::JSONConfig &jsonconfig)
Make a LWT DNN from the JSON config object.
Definition RivetLWTNN.hh:48
std::unique_ptr< lwt::LightweightGraph > mkGraphLWTNN(const lwt::GraphConfig &graphconfig)
Make a LWT Graph from the JSON config object.
Definition RivetLWTNN.hh:59
Error for I/O failures.
Definition Exceptions.hh:73