Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Example: Transfer Learning PINN

Crate: kwavers
Run: cargo run -p kwavers --example transfer_learning_pinn --features pinn
Source: crates/kwavers/examples/transfer_learning_pinn.rs

What This Example Demonstrates

This example shows how a pre-trained 2-D wave PINN can be adapted to a new geometry using fine-tuning and selective layer freezing. It is the shortest example for learning the transfer-learning API in the PINN stack.

ComponentAPIValue
Source modelPinnWave2D::<Backend>::new(PinnConfig2D::default())Starts from a ready-made baseline model configuration
Transfer configTransferLearningConfigUses 1e-4 fine-tuning LR, 10 epochs, and FreezeAllButLast
Adaptation callTransferLearner::transfer_to_geometryTransfers the model to a new rectangular target geometry

Key Code Snippet

let transfer_config = TransferLearningConfig {
    fine_tune_lr: 1e-4,
    fine_tune_epochs: 10,
    freeze_strategy: FreezeStrategy::FreezeAllButLast,
    patience: 3,
    wave_speed: 1500.0,
};

let mut learner = TransferLearner::new(source_model, transfer_config);

Expected Output (if applicable)

With the pinn feature enabled, the program prints initial/final accuracy and convergence epochs; otherwise it prints the feature-enablement command.

Book Chapter

← Inverse Problems and Physics-Informed Neural Networks