LibtorchNeuralNetControl

Controls the value of multiple controllable input parameters using a Libtorch-based neural network.

Overview

This object controls a physical process using a neural network. The neural network can be either read from a file of transferred from a trainer. One can use the "filename" parameter to load the neural network from file. This capability supports two formats:

  • Reading entire neural networks using a TorchScript format in which case the user needs to specify "torch_script_format" parameter;

  • Reading neural network parameters from a binary (usually .net) file. In this case only parameters are read meaning that the structure of the neural network is not established in advance. For this reason, we need to specify the architecture using "num_neurons_per_layer" and "activation_function" parameters.

Input Parameters

  • parametersThe input parameter(s) to control.

    C++ Type:std::vector<std::string>

    Controllable:No

    Description:The input parameter(s) to control.

  • responsesThe responses (prostprocessors) which are used for the control.

    C++ Type:std::vector<PostprocessorName>

    Unit:(no unit assumed)

    Controllable:No

    Description:The responses (prostprocessors) which are used for the control.

Required Parameters

  • action_scaling_factorsScale factor that multiplies the NN output to obtain a physically meaningful value.

    C++ Type:std::vector<double>

    Unit:(no unit assumed)

    Controllable:No

    Description:Scale factor that multiplies the NN output to obtain a physically meaningful value.

  • activation_functionrelu The type of activation functions to use. It is either one value or one value per hidden layer.

    Default:relu

    C++ Type:std::vector<std::string>

    Controllable:No

    Description:The type of activation functions to use. It is either one value or one value per hidden layer.

  • depends_onThe Controls that this control relies upon (i.e. must execute before this one)

    C++ Type:std::vector<std::string>

    Controllable:No

    Description:The Controls that this control relies upon (i.e. must execute before this one)

  • execute_onINITIAL TIMESTEP_ENDThe list of flag(s) indicating when this object should be executed. For a description of each flag, see https://mooseframework.inl.gov/source/interfaces/SetupInterface.html.

    Default:INITIAL TIMESTEP_END

    C++ Type:ExecFlagEnum

    Options:XFEM_MARK, FORWARD, ADJOINT, HOMOGENEOUS_FORWARD, ADJOINT_TIMESTEP_BEGIN, ADJOINT_TIMESTEP_END, NONE, INITIAL, LINEAR, NONLINEAR_CONVERGENCE, NONLINEAR, POSTCHECK, TIMESTEP_END, TIMESTEP_BEGIN, MULTIAPP_FIXED_POINT_END, MULTIAPP_FIXED_POINT_BEGIN, FINAL, CUSTOM, PRE_MULTIAPP_SETUP

    Controllable:No

    Description:The list of flag(s) indicating when this object should be executed. For a description of each flag, see https://mooseframework.inl.gov/source/interfaces/SetupInterface.html.

  • filenameDefine if the neural net is supposed to be loaded from a file.

    C++ Type:std::string

    Controllable:No

    Description:Define if the neural net is supposed to be loaded from a file.

  • input_timesteps1Number of time steps to use in the input data, if larger than 1, data from the previous timesteps will be used as well as inputs in the training.

    Default:1

    C++ Type:unsigned int

    Controllable:No

    Description:Number of time steps to use in the input data, if larger than 1, data from the previous timesteps will be used as well as inputs in the training.

  • num_neurons_per_layerThe number of neurons on each hidden layer.

    C++ Type:std::vector<unsigned int>

    Controllable:No

    Description:The number of neurons on each hidden layer.

  • response_scaling_factorsConstants which will be used to multiply the shifted response values. This is used for the manipulation of the neural net inputs for better training efficiency.

    C++ Type:std::vector<double>

    Unit:(no unit assumed)

    Controllable:No

    Description:Constants which will be used to multiply the shifted response values. This is used for the manipulation of the neural net inputs for better training efficiency.

  • response_shift_factorsConstants which will be used to shift the response values. This is used for the manipulation of the neural net inputs for better training efficiency.

    C++ Type:std::vector<double>

    Unit:(no unit assumed)

    Controllable:No

    Description:Constants which will be used to shift the response values. This is used for the manipulation of the neural net inputs for better training efficiency.

  • torch_script_formatFalseIf we want to load the neural net using the torch-script format.

    Default:False

    C++ Type:bool

    Controllable:No

    Description:If we want to load the neural net using the torch-script format.

Optional Parameters

  • control_tagsAdds user-defined labels for accessing object parameters via control logic.

    C++ Type:std::vector<std::string>

    Controllable:No

    Description:Adds user-defined labels for accessing object parameters via control logic.

  • enableTrueSet the enabled status of the MooseObject.

    Default:True

    C++ Type:bool

    Controllable:No

    Description:Set the enabled status of the MooseObject.

  • implicitTrueDetermines whether this object is calculated using an implicit or explicit form

    Default:True

    C++ Type:bool

    Controllable:No

    Description:Determines whether this object is calculated using an implicit or explicit form

Advanced Parameters

Input Files

Child Objects

warningwarning

The detailed documentation of this object is only available when Moose is compiled with Libtorch. For instructions on how to compile Moose with Libtorch, visit the general installation webpage or click here.