#include <LibtorchArtificialNeuralNet.h>
| Public Member Functions | |
| LibtorchArtificialNeuralNet (const std::string name, const unsigned int num_inputs, const unsigned int num_outputs, const std::vector< unsigned int > &num_neurons_per_layer, const std::vector< std::string > &activation_function={"relu"}, const torch::DeviceType device_type=torch::kCPU, const torch::ScalarType scalar_type=torch::kDouble) | |
| Construct using input parameters.  More... | |
| LibtorchArtificialNeuralNet (const Moose::LibtorchArtificialNeuralNet &nn) | |
| Copy construct an artificial neural network.  More... | |
| virtual void | addLayer (const std::string &layer_name, const std::unordered_map< std::string, unsigned int > ¶meters) | 
| Add layers to the neural network.  More... | |
| virtual torch::Tensor | forward (const torch::Tensor &x) override | 
| Overriding the forward substitution function for the neural network, unfortunately this cannot be const since it creates a graph in the background.  More... | |
| const std::string & | name () const | 
| Return the name of the neural network.  More... | |
| unsigned int | numInputs () const | 
| Return the number of neurons on the input layer.  More... | |
| unsigned int | numOutputs () const | 
| Return the number of neurons on the output layer.  More... | |
| unsigned int | numHiddenLayers () const | 
| Return the number of hidden layers.  More... | |
| const std::vector< unsigned int > & | numNeuronsPerLayer () const | 
| Return the hidden layer architecture.  More... | |
| const MultiMooseEnum & | activationFunctions () const | 
| Return the multi enum containing the activation functions.  More... | |
| torch::DeviceType | deviceType () const | 
| Return the device which is used by this neural network.  More... | |
| torch::ScalarType | dataType () const | 
| Return the data type which is used by this neural network.  More... | |
| void | constructNeuralNetwork () | 
| Construct the neural network.  More... | |
| void | store (nlohmann::json &json) const | 
| Store the network architecture in a json file (for debugging, visualization)  More... | |
| Protected Attributes | |
| const std::string | _name | 
| Name of the neural network.  More... | |
| std::vector< torch::nn::Linear > | _weights | 
| Submodules that hold linear operations and the corresponding weights and biases (y = W * x + b)  More... | |
| const unsigned int | _num_inputs | 
| const unsigned int | _num_outputs | 
| Number of neurons on the output layer.  More... | |
| const std::vector< unsigned int > | _num_neurons_per_layer | 
| Hidden layer architecture.  More... | |
| MultiMooseEnum | _activation_function | 
| Activation functions (either one for all hidden layers or one for every layer separately)  More... | |
| const torch::DeviceType | _device_type | 
| The device type used for this neural network.  More... | |
| const torch::ScalarType | _data_type | 
| The data type used in this neural network.  More... | |
Definition at line 26 of file LibtorchArtificialNeuralNet.h.
| Moose::LibtorchArtificialNeuralNet::LibtorchArtificialNeuralNet | ( | const std::string | name, | 
| const unsigned int | num_inputs, | ||
| const unsigned int | num_outputs, | ||
| const std::vector< unsigned int > & | num_neurons_per_layer, | ||
| const std::vector< std::string > & | activation_function = {"relu"}, | ||
| const torch::DeviceType | device_type = torch::kCPU, | ||
| const torch::ScalarType | scalar_type = torch::kDouble | ||
| ) | 
Construct using input parameters.
| name | Name of the neural network | 
| num_inputs | The number of input neurons/parameters | 
| num_neurons_per_layer | Number of neurons per hidden layer | 
| num_outputs | The number of output neurons | 
Definition at line 18 of file LibtorchArtificialNeuralNet.C.
| Moose::LibtorchArtificialNeuralNet::LibtorchArtificialNeuralNet | ( | const Moose::LibtorchArtificialNeuralNet & | nn | ) | 
Copy construct an artificial neural network.
| nn | The neural network which needs to be copied | 
Definition at line 44 of file LibtorchArtificialNeuralNet.C.
| 
 | inline | 
Return the multi enum containing the activation functions.
Definition at line 77 of file LibtorchArtificialNeuralNet.h.
| 
 | virtual | 
Add layers to the neural network.
| layer_name | The name of the layer to be added | 
| parameters | A map of parameter names and the corresponding values which describe the neural net layer architecture | 
Definition at line 118 of file LibtorchArtificialNeuralNet.C.
Referenced by constructNeuralNetwork().
| void Moose::LibtorchArtificialNeuralNet::constructNeuralNetwork | ( | ) | 
Construct the neural network.
Definition at line 66 of file LibtorchArtificialNeuralNet.C.
Referenced by LibtorchArtificialNeuralNet().
| 
 | inline | 
Return the data type which is used by this neural network.
Definition at line 81 of file LibtorchArtificialNeuralNet.h.
| 
 | inline | 
Return the device which is used by this neural network.
Definition at line 79 of file LibtorchArtificialNeuralNet.h.
| 
 | overridevirtual | 
Overriding the forward substitution function for the neural network, unfortunately this cannot be const since it creates a graph in the background.
| x | Input tensor for the evaluation | 
Implements Moose::LibtorchNeuralNetBase.
Definition at line 88 of file LibtorchArtificialNeuralNet.C.
| 
 | inline | 
Return the name of the neural network.
Definition at line 67 of file LibtorchArtificialNeuralNet.h.
| 
 | inline | 
Return the number of hidden layers.
Definition at line 73 of file LibtorchArtificialNeuralNet.h.
Referenced by constructNeuralNetwork().
| 
 | inline | 
Return the number of neurons on the input layer.
Definition at line 69 of file LibtorchArtificialNeuralNet.h.
| 
 | inline | 
Return the hidden layer architecture.
Definition at line 75 of file LibtorchArtificialNeuralNet.h.
| 
 | inline | 
Return the number of neurons on the output layer.
Definition at line 71 of file LibtorchArtificialNeuralNet.h.
| void Moose::LibtorchArtificialNeuralNet::store | ( | nlohmann::json & | json | ) | const | 
Store the network architecture in a json file (for debugging, visualization)
Definition at line 138 of file LibtorchArtificialNeuralNet.C.
Referenced by Moose::to_json().
| 
 | protected | 
Activation functions (either one for all hidden layers or one for every layer separately)
Definition at line 102 of file LibtorchArtificialNeuralNet.h.
Referenced by activationFunctions(), forward(), and LibtorchArtificialNeuralNet().
| 
 | protected | 
The data type used in this neural network.
Definition at line 106 of file LibtorchArtificialNeuralNet.h.
Referenced by constructNeuralNetwork(), dataType(), and forward().
| 
 | protected | 
The device type used for this neural network.
Definition at line 104 of file LibtorchArtificialNeuralNet.h.
Referenced by constructNeuralNetwork(), deviceType(), and forward().
| 
 | protected | 
Name of the neural network.
Definition at line 90 of file LibtorchArtificialNeuralNet.h.
Referenced by name().
| 
 | protected | 
Definition at line 95 of file LibtorchArtificialNeuralNet.h.
Referenced by constructNeuralNetwork(), and numInputs().
| 
 | protected | 
Hidden layer architecture.
Definition at line 99 of file LibtorchArtificialNeuralNet.h.
Referenced by constructNeuralNetwork(), LibtorchArtificialNeuralNet(), numHiddenLayers(), and numNeuronsPerLayer().
| 
 | protected | 
Number of neurons on the output layer.
Definition at line 97 of file LibtorchArtificialNeuralNet.h.
Referenced by constructNeuralNetwork(), and numOutputs().
| 
 | protected | 
Submodules that hold linear operations and the corresponding weights and biases (y = W * x + b)
Definition at line 93 of file LibtorchArtificialNeuralNet.h.
Referenced by addLayer(), constructNeuralNetwork(), and forward().
 1.8.14
 1.8.14