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