Utilities
We provide a distributed relative L2 loss but most distributed loss functions should be straight-forward to build with ParametricOperators.jl
ParametricDFNOs.UTILS.dist_loss
— Methoddist_loss(local_pred_y, local_true_y)
Calculates the distributed normalized root mean squared error (NRMSE) between predicted and actual values.
Arguments
local_pred_y
: Local tensor of predicted values, typically a subset of the whole prediction corresponding to the data handled by a specific node.local_true_y
: Local tensor of actual values corresponding to a subset of the data
Returns
- A scalar value representing the relative L2 error of the predictions to the true values, which quantifies the prediction error normalized by the magnitude of the actual values.
ParametricDFNOs.UTILS.dist_read_tensor
— Methoddist_read_tensor(file_name, key, indices)
Reads a tensor slice from an HDF5 file based on provided indices and reshapes the result.
Arguments
file_name
: The name or path of the HDF5 file from which data is to be read.key
: The key within the HDF5 file that corresponds to the dataset of interest.indices
: The indices specifying the slice of the dataset to be extracted.
Returns
- A reshaped array where the first dimension is singleton, extending the dimensions of the original data slice by one.
Functionality
- Opens an HDF5 file in read-only mode.
- Accesses the dataset associated with the provided
key
. - Extracts the slice of the dataset specified by
indices
. - Reshapes the extracted data, adding a singleton dimension at the beginning.
Example Usage
# To read a specific slice from a dataset within an HDF5 file
tensor_data = dist_read_tensor("data.h5", "dataset_key", (1:10, 5:15, 2:2))
GPU Helpers
ParametricDFNOs.DFNO_2D.set_gpu_flag
— Methodset_gpu_flag(flag::Bool)
Function to set the gpu_flag and update device accordingly. Should be set at the beginning of your script. All FNO computatation following this will use the device set.
ParametricDFNOs.DFNO_3D.set_gpu_flag
— Methodset_gpu_flag(flag::Bool)
Function to set the gpu_flag and update device accordingly. Should be set at the beginning of your script. All FNO computatation following this will use the device set.