pinnx.utils module#
Internal utilities.
This module provides utility functions for array operations, data conversion, visualization, sampling, and other helper functions used throughout PINNx.
Conversion Helpers#
Functions for converting between dictionary and array representations.
Convert args to a dictionary. |
|
Convert a dictionary to an array. |
Array Operations#
Utilities for tensor and array manipulation.
Convert a list of numpy arrays or tensors to a numpy array or a tensor. |
|
Training Utilities#
Functions for training, visualization, and result management.
apply: Apply a function element-wise.
standardize: Standardize data to zero mean and unit variance.
saveplot: Save and plot training results.
plot_loss_history: Plot loss history over iterations.
save_loss_history: Save loss history to file.
plot_best_state: Plot best model state.
save_best_state: Save best model state.
dat_to_csv: Convert .dat files to .csv format.
isclose: Check if values are close within tolerance.
smart_numpy: Convert to NumPy array intelligently.
Launch a new process to call the function. |
|
Standardize features by removing the mean and scaling to unit variance. |
|
Save/plot the loss history and best trained result. |
|
Plot the training and testing loss history. |
|
Save the training and testing loss history to a file. |
|
Plot the best result of the smallest training loss. |
|
Save the best result of the smallest training loss to a file. |
|
Converts a dat file to CSV format and saves it. |
|
A modified version of np.isclose for DeepXDE. |
|
Internal Helpers#
Internal utility functions for PINNx operations.
Decorator for measuring the execution time of methods. |
|
Get a sub-dictionary from a dictionary. |
|
numpy.vectorize wrapper that works with instance methods. |
|
Convert the output to a Tensor. |
|
Create numpy ndarrays that shares the same underlying storage, if possible. |
|
Convert two lists or two variables into a dictionary. |
|
Loss Functions#
Loss functions for training neural networks.
Retrieves a loss function. |
Sampling Helpers#
Batch sampling utilities.
Samples a mini-batch of indices. |
Sampling Strategies#
Point sampling strategies for training data generation.
sample: Generic sampling function.
pseudorandom: Pseudorandom sampling.
quasirandom: Quasi-random (low-discrepancy) sampling.
InitialPointGenerator: Generates initial training points.
check_random_state: Validates random state.
check_dimension: Validates dimension parameter.
Generate pseudorandom or quasirandom samples in [0, 1]^dimension. |
|
Pseudo random. |
|
Turn a provided dimension description into a dimension object. |
Transformers#
Data transformation and preprocessing utilities.
Transformer: Base transformer class.
Identity: Identity transformation.
StringEncoder: Encode strings to numerical values.
LogN: Logarithmic transformation.
CategoricalEncoder: Encode categorical variables.
LabelEncoder: Encode labels.
Normalize: Normalize data.
Pipeline: Chain multiple transformers.
Base class for all 1-D transformers. |
|
Identity transform. |
|
StringEncoder transform. |
|
Base N logarithm transform. |
|
OneHotEncoder that can handle categorical variables. |
|
LabelEncoder that can handle categorical variables. |
|
Scales each dimension into the interval [0, 1]. |
|
A lightweight pipeline to chain transformers. |