9 #include <trg/cdc/NeuroTrigger.h>
10 #include <trg/cdc/NeuroTriggerParameters.h>
11 #include <trg/cdc/dataobjects/CDCTriggerMLP.h>
12 #include <nlohmann/json.hpp>
18 int 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;
44 for (
auto node : nets[
"expert_" + std::to_string(expert)][
"weights"][
"model.net.0.weight"]) {
45 for (
float w : node) {
48 weights.push_back(nets[
"expert_" + std::to_string(expert)][
"weights"][
"model.net.0.bias"][numnode]);
52 for (
auto node : nets[
"expert_" + std::to_string(expert)][
"weights"][
"model.net.2.weight"]) {
53 for (
float w : node) {
56 weights.push_back(nets[
"expert_" + std::to_string(expert)][
"weights"][
"model.net.2.bias"][numnode]);
59 std::cout <<
" writing " << weights.size() <<
" weights for expert " << expert << std::endl;
60 m_nnt[expert].setWeights(weights);
62 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.
int main(int argc, char **argv)
Run all tests.