ptyrad.utils.dev_tools#

Developer tools for logging, testing, checking sizes and types, etc.

Functions

check_modes_ortho(tensor[, rtol])

Check if the modes in tensor (Nmodes, []) is orthogonal to each other

get_size_bytes(x)

has_nan_or_inf(tensor)

Check if a torch.Tensor contains any NaN or Inf values.

print_package_tree(package_path)

print_package_tree prints the package structure with module, class, method, and function definitions for a concise view of the entire package structure

test_constraint_fn(test_model, ...)

Test run of the constraint_fn

test_loss_fn(model, indices, loss_fn)

Print loss values for each term for convenient weight tuning

ptyrad.utils.dev_tools.print_package_tree(package_path)[source]#

print_package_tree prints the package structure with module, class, method, and function definitions for a concise view of the entire package structure

Parameters:

package_path (str) – package_path (str): Path to the target package

ptyrad.utils.dev_tools.has_nan_or_inf(tensor)[source]#

Check if a torch.Tensor contains any NaN or Inf values.

Parameters:

tensor (torch.Tensor) – Input tensor to check.

Returns:

True if the tensor contains any NaN or Inf values, False otherwise.

Return type:

bool

ptyrad.utils.dev_tools.get_size_bytes(x)[source]#
ptyrad.utils.dev_tools.check_modes_ortho(tensor, rtol=0.001)[source]#

Check if the modes in tensor (Nmodes, []) is orthogonal to each other

ptyrad.utils.dev_tools.test_loss_fn(model, indices, loss_fn)[source]#

Print loss values for each term for convenient weight tuning

ptyrad.utils.dev_tools.test_constraint_fn(test_model, constraint_fn, plot_forward_pass)[source]#

Test run of the constraint_fn