GpuPINNTrainer<T>
Models & Types · AiDotNet.PhysicsInformed
Provides GPU-accelerated training for Physics-Informed Neural Networks.
How It Works
For Beginners: This trainer provides GPU-accelerated training methods for PINNs. It can significantly speed up training by:
- Processing large batches of collocation points in parallel
- Performing matrix operations on the GPU
- Using asynchronous data transfers to overlap computation
Usage:
var architecture = new NeuralNetworkArchitecture<double>(
InputType.OneDimensional, NeuralNetworkTaskType.Regression, inputSize: 2, outputSize: 1);
var myPinn = new PhysicsInformedNeuralNetwork<double>(
architecture,
new HeatEquation<double>(),
Array.Empty<IBoundaryCondition<double>>());
var trainer = new GpuPINNTrainer<double>(myPinn);
var history = trainer.Train(epochs: 10000, learningRate: 0.001);
The trainer automatically falls back to CPU if GPU is not available.
Constructors
| Constructor | Summary |
|---|---|
GpuPINNTrainer(PhysicsInformedNeuralNetwork<T> pinn, GpuPINNTrainingOptions options) |
Initializes a new instance of the GPU PINN trainer. |
Properties
| Property | Summary |
|---|---|
GpuPINNTrainingOptions Options { get; } |
Gets the current training options. |
PhysicsInformedNeuralNetwork<T> Network { get; } |
Gets the underlying PINN being trained. |
bool IsUsingGpu { get; } |
Gets whether GPU is currently being used for training. |
Methods
| Method | Summary |
|---|---|
GpuTrainingHistory<T> Train(Tensor<T> dataInputs, Tensor<T> dataOutputs, int epochs, double learningRate, bool verbose) |
Trains the PINN with GPU acceleration. |
PINNGpuMemoryInfo GetGpuMemoryInfo() |
Gets GPU memory usage statistics. |
T EvaluateLoss(Tensor<T> batchInputs, Tensor<T> batchTargets) |
Performs a forward pass and computes loss (does not update weights). |
bool TryInitializeGpu() |
Attempts to initialize GPU resources. |
void ReleaseGpuResources() |
Releases GPU resources. |
void UpdateOptions(GpuPINNTrainingOptions options) |
Updates training options. |