10 #ifdef LIBTORCH_ENABLED 59 template <
typename SamplerType = torch::data::samplers::DistributedSequentialSampler>
86 const unsigned int num_batches);
96 const unsigned int num_ranks);
103 static std::unique_ptr<torch::optim::Optimizer>
LibtorchArtificialNeuralNetTrainer(LibtorchArtificialNeuralNet &nn, const Parallel::Communicator &comm)
Construct using the neural network and a parallel communicator.
unsigned int num_batches
Number of batches we want to split the dataset into.
bool print_loss
If we want to print additional information during training.
const Parallel::Communicator & comm() const
Templated class which is responsible for training LibtorchArtificialNeuralNets.
static unsigned int computeLocalBatchSize(const unsigned int batch_size, const unsigned int num_ranks)
Computes the number of local samples.
This class is a wrapper around a libtorch dataset which can be used by the data loaders in the neural...
unsigned int parallel_processes
The number of allowed parallel processes.
bool allow_duplicates
Parameter for sampling.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Real learning_rate
The learning rate for the optimizers.
MooseEnum optimizer_type
The type of optimizer we want to use for training, adam is the default due to its robustness and fast...
LibtorchArtificialNeuralNet & _nn
Reference to the neural network which is trained.
Real rel_loss_tol
The relative loss tolerance where the training shall stop.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void train(LibtorchDataset &dataset, const LibtorchTrainingOptions &options)
Train the neural network using a given (serialized) data and options for the training process...
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
unsigned int num_epochs
Number of iterations we want to perform on the whole dataset.
static unsigned int computeBatchSize(const unsigned int num_samples, const unsigned int num_batches)
Computes the number of samples used for each batch.
A struct containing necessary information for training neural networks.
unsigned int print_epoch_loss
The frequency of training loss print to console.
static std::unique_ptr< torch::optim::Optimizer > createOptimizer(const LibtorchArtificialNeuralNet &nn, const LibtorchTrainingOptions &options)
Setup the optimizer based on the provided options.