9#include <trg/cdc/NeuroTrigger.h>
10#include <trg/cdc/NeuroTriggerParameters.h>
11#include <trg/cdc/dataobjects/CDCTriggerMLP.h>
12#include <nlohmann/json.hpp>
18int main(
int argc,
const char* argv[])
23 std::cout <<
"Program needs at 3 arguments:" << std::endl
24 <<
" 1: json weights" << std::endl
25 <<
" 2: configuration file name" << std::endl
26 <<
" 3: output filename" << std::endl;
29 std::string jsonweights = argv[1];
30 std::string configfile = argv[2];
31 std::string outputfile = argv[3];
36 std::ifstream netfile(jsonweights, std::ifstream::binary);
40 for (
unsigned expert = 0; expert < m_nnt.
nSectors(); expert++) {
42 std::vector<float> weights;
43 for (
unsigned i = 0; i < nets[
"expert_" + std::to_string(expert)][
"shapes"].size(); i = i + 2) {
45 for (
auto node : nets[
"expert_" + std::to_string(expert)][
"weights"][
"model.net." + std::to_string(i) +
".weight"]) {
46 for (
float w : node) {
49 weights.push_back(nets[
"expert_" + std::to_string(expert)][
"weights"][
"model.net." + std::to_string(i) +
".bias"][numnode]);
53 std::cout <<
" writing " << weights.size() <<
" weights for expert " << expert << std::endl;
54 m_nnt[expert].setWeights(weights);
56 m_nnt.
save(outputfile,
"MLPs");
Class to represent the CDC Neurotrigger.
void initialize(const Parameters &p)
Set parameters and get some network independent parameters.
void save(const std::string &filename, const std::string &arrayname="MLPs")
Save MLPs to file.
unsigned nSectors() const
return number of neural networks
Abstract base class for different kinds of events.