LibtorchTorchScriptNeuralNet

Overview

This object can be used to create a neural network which is read from a torch-script file which can be exported using pytorch in python. For instruction on how to save a neural network using the torch-script format using pytorch, click here!

Example usage

Within MOOSE a torchscript-based neural network can be created using the name of the torch-script file:

  // We read the neural net from a file which was prepared in python
  std::shared_ptr<Moose::LibtorchNeuralNetBase> nn =
      std::make_shared<Moose::LibtorchTorchScriptNeuralNet>(getParam<std::string>("filename"));
(moose/test/src/libtorch/vectorpostprocessors/LibtorchTorchScriptNeuralNetTest.C)