LibtorchANNSurrogate
Overview
The details of a simple feedforward neural network is discussed in LibtorchArtificialNeuralNet. This class is dedicated to evaluating the following function:
(1)which describes a neural network of layers. In this context, denotes an activation function, while and are the input and output arguments. respectively. The weight matrices () and bias vectors () are optimized by LibtorchANNTrainer and are fixed in the evaluation phase.
Example Input File Syntax
Let us consider an example where we evaluate the neural network trained here. For this, prepare another set of samples of from the same parameter space:
[Samplers<<<{"href": "../../../syntax/Samplers/index.html"}>>>]
[test]
type = CartesianProduct<<<{"description": "Provides complete Cartesian product for the supplied variables.", "href": "../../samplers/CartesianProductSampler.html"}>>>
linear_space_items<<<{"description": "A list of triplets, each item should include the min, step size, and number of steps."}>>> = '0 0.05 2
0 0.05 2
0 0.05 2'
[]
[]
(moose/modules/stochastic_tools/test/tests/surrogates/libtorch_nn/evaluate.i)Following this, we load the surrogate from a file saved by the trainer:
[Surrogates<<<{"href": "../../../syntax/Surrogates/index.html"}>>>]
[surr]
type = LibtorchANNSurrogate
filename = 'train_out_train.rd'
[]
[]
(moose/modules/stochastic_tools/test/tests/surrogates/libtorch_nn/evaluate.i)And evaluate it using a reporter which uses the samples and the surrogate to compute the approximate values of the target function at the new sample points:
[Reporters<<<{"href": "../../../syntax/Reporters/index.html"}>>>]
[results]
type = EvaluateSurrogate<<<{"description": "Tool for sampling surrogate models.", "href": "../../reporters/EvaluateSurrogate.html"}>>>
model<<<{"description": "Name of surrogate models."}>>> = surr
sampler<<<{"description": "Sampler to use for evaluating surrogate models."}>>> = test
execute_on<<<{"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."}>>> = FINAL
parallel_type<<<{"description": "This parameter will determine how the stochastic data is gathered. It is common for outputting purposes that this parameter be set to ROOT, otherwise, many files will be produced showing the values on each processor. However, if there are lot of samples, gathering on root may be memory restrictive."}>>> = ROOT
[]
[]
(moose/modules/stochastic_tools/test/tests/surrogates/libtorch_nn/evaluate.i)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.