Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #ifdef LIBTORCH_ENABLED 11 : 12 : #pragma once 13 : 14 : #include <torch/torch.h> 15 : #include "LibtorchArtificialNeuralNet.h" 16 : #include "GeneralReporter.h" 17 : #include "nlohmann/json.h" 18 : 19 : /** 20 : * A Reporter which can print the parameter values of a 21 : * LibtorchArtificialNeuralNetwork from within a Controller object. 22 : */ 23 : class LibtorchArtificialNeuralNetParameters : public GeneralReporter 24 : { 25 : public: 26 : static InputParameters validParams(); 27 : 28 : LibtorchArtificialNeuralNetParameters(const InputParameters & params); 29 : 30 1 : void initialize() override{}; 31 : void execute() override; 32 1 : void finalize() override{}; 33 : 34 : void initialSetup() override; 35 : 36 : protected: 37 : /// The name of the control objects which hold the neural networks 38 : const std::string _control_name; 39 : 40 : /// Pointer to the controller so that we can avoid warehouse lookups in the execute function 41 : const LibtorchNeuralNetControl * _controller; 42 : 43 : /// Reference to a neural net pointer declared as a reporter. 44 : /// The parameters of this network are printed into a json file. 45 : const Moose::LibtorchArtificialNeuralNet *& _network; 46 : }; 47 : 48 : #endif